indent preformatted text by 4 spaces
#include <iostream>
using namespace std;
class Test
{
private:
int x = 10;
int newArray[x];
public:
};
int main()
{
return 0;
}
Khi chạy code này, nó báo lỗi là "invalid use of non-static data member ‘Test::x’ ". Nhưng nếu chuyển phần khai báo newArray vào constructor thì nó lại chạy được. Tại sao lại như thế? Mong mọi người giải thích giúp mình.