, , , , - , , , , , , - , , , , , - , , , , :
int a;
cin >> a;
int * b = new int[a];
The correct way to declare an array with an unknown size (the size determined at runtime) is to integrate it with your class here, as you do, and remember that any private or public attributes of the class have no memory, just slowdown should never contain any inference otherwise in methods or outside the class, since they are publicly available in your case and, of course, after the declaration of the class instance, for example Test t; in any way here, as you do in class:
class Test
{
public:
int a;
int * p;
Test(int Ia=1) {
a = Ia;
b = new int[a];
}
~Test() { delete b; }
};
source
share