struct Test {
int w, h;
int * p;
};
int main(){
Test t {
10,
20,
new int[this->h*this->w]
};
return 0;
}
我只想在初始化中使用w和h,有什么办法做到这一点?
考虑这个少一些琐碎的例子
struct Test {
int w, h;
std::unique_ptr<int[]> p;
Test(int w_, int h_) : w(w_), h(_), p(std::make_unique<int[]>(w_*h_) { }
};