By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,288 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

usage of undefined class

P: n/a
Hello,

I would like to define a class (ListA) which can store elements of
another class (A). The problem is, that I want to use this class (ListA)
inside class A. (See code below.)
Of course I could use void* instead of A* in ListA but I would prefer a
way where do not always have to cast my pointers.
Is there a possibility to realize it (kind of) this way?

Thanks in advance!
Kris

class ListA {
private:
A * head;
public:
bool Add ( A * );
A * operator [] ( unsigned int );
...
};

class A {
public:
ListA * foo;
...
};

Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Kristoffer Mögle" <mo**@hrz.tu-chemnitz.de> a écrit dans le message de
news: br**********@anderson.hrz.tu-chemnitz.de...
Hello,

I would like to define a class (ListA) which can store elements of
another class (A). The problem is, that I want to use this class (ListA)
inside class A. (See code below.)
Of course I could use void* instead of A* in ListA but I would prefer a
way where do not always have to cast my pointers.
Is there a possibility to realize it (kind of) this way?

Thanks in advance!
Kris

class ListA {
private:
A * head;
public:
bool Add ( A * );
A * operator [] ( unsigned int );
...
};

class A {
public:
ListA * foo;
...
};


try this :

class A;

class ListA;

class ListA

{

A *m_pA;

};

class A

{

ListA *m_pListA;

};

should compile fine.

Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.