gr*********@axis.hu wrote:
I redefined it as you indicated and I added a new constructor but I
need one more thing.
The class looks like this:
class A {
private:
char* name;
A* a[];
public:
A();
A(char* p_name);
A(char* p_name, A* p_a);
~A();
}
How should implement the constructors?
Surely that depends on what you want to do?
Part of the problem here is that you are using illegal syntax.
class A {
private:
char* name;
A* a[];
This is not legal C++. Your compiler might be accepting it but your
compiler is wrong. When you declare an array in C++ you have to say how
big it is. This is legal
class A {
private:
char* name;
A* a[10];
Now I'm guessing, but I would say that Neelesh Bodas misunderstood what
you want. I think that problably you want a dynamic array of A objects
inside your A class. That is perfectly legal, and you write it like this
class A {
private:
char* name;
A* a;
In the constructor you dynamically allocate however many A objects you
want. Like this
a = new A[n];
where n is the number of A objects you want.
John