anpatel
anpatel

Reputation: 1952

Use private-class members inside other private-class members

I am fairly new to C++ and am wondering if I am allowed to do the following:

class oFoo{
  ...
}

class Foo{
   int x;
   oFoo* oArray[x];
 public:
   Foo(int xVal);
   Foo~(); 
}

Am I allowed to use x as the bound for the array of pointers to class oFoo??

Upvotes: 0

Views: 56

Answers (1)

Naveen
Naveen

Reputation: 73443

No, only compile time constants are allowed. If you require dynamic array take a look at std::vector.

Upvotes: 3

Related Questions