I have defined two structs
class foo() {
public:
struct spatialEntry {
bool block;
CoherenceState_t state;
};
struct accumulationEntry {
uint64_t offset;
std::vector<spatialEntry> pattern;
};
std::vector<int> v;
std::list<accumulationEntry> accumulationTable;
foo() {
v.resize(16);
}
};
Now I want to initialize the size of std::vector<spatialEntry> to 16 like v. How can I do that?
Just define a constructor for the class which contains that member and then
resize()as:But then if you use
resize, then it is better to do that as :That is, use member-initialization list. Do the same for
fooalso.