新手警报。我有以下课程
看法
class View {
public:
explicit View(const TupleSchema& schema)
: schema_(schema),
columns_(new Column[schema.attribute_count()]),
row_count_(0) {
}
View(const View& other)
: schema_(other.schema()),
columns_(new Column[other.schema().attribute_count()]),
row_count_(0) {
}
explicit View(const View& other, rowcount_t offset, rowcount_t row_count)
: schema_(other.schema()),
columns_(new Column[other.schema().attribute_count()]),
row_count_(0) {
}
View(const Column& column, rowcount_t row_count)
: schema_(TupleSchema::Singleton(column.attribute().name(),
column.attribute().type(),
column.attribute().nullability())),
columns_(new Column[1]),
row_count_(row_count) {
}
private:
const TupleSchema schema_;
scoped_array<Column> columns_;
rowcount_t row_count_;
};
堵塞
class Block {
public:
Block(const TupleSchema& schema, BufferAllocator* allocator)
: allocator_(allocator),
columns_(new OwnedColumn[schema.attribute_count()]),
view_(schema) {
}
}
}
private:
BufferAllocator* const allocator_;
scoped_array<OwnedColumn> columns_;
View view_; // Full view on the entire block.
DISALLOW_COPY_AND_ASSIGN(Block);
};
查看复印机
class ViewCopier : public BaseViewCopier {
public:
ViewCopier(const TupleSchema& schema, bool deep_copy);
ViewCopier(const BoundSingleSourceProjector* projector, bool deep_copy);
};
当我将上述内容用作另一个类中的成员并为它编写一个构造函数时,如下所示
class SegmentedTable : public BasicOperation {
public:
SegmentedTable::SegmentedTable(const std::vector<TupleSchema> vp_schemas, BufferAllocator* buffer_allocator)
: BasicOperation(),
view_copier_(NULL, NULL) { }
private:
scoped_ptr<Block> block_;
View view_;
ViewCopier view_copier_;
}
我收到一条错误消息,指出没有定义方法 View::View()。我理解这是因为不需要 View() 类的构造函数,因为它会在 SegmentedTable 构造函数的初始化列表中自动初始化。但是我有2个问题
1)为什么 Block 不需要相同的东西。
2) 为什么我可以用 ViewCopier(NULL, NULL) 初始化 ViewCopier 而我不能为 View 这样做。执行 View(NULL) 还告诉我没有定义方法 View::View(NULL) 。
我知道我没有提供示例中使用的其他一些类定义,但我希望没有它们就可以回答这个问题。