class member that is that class

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2008
Posts: 1
Reputation: price is an unknown quantity at this point 
Solved Threads: 0
price price is offline Offline
Newbie Poster

class member that is that class

 
0
  #1
Nov 20th, 2008
Hello,

I'm programming in C++. Is it possible to have a private data member of type class X within the definition of class X? For example,

  1. class X
  2. {
  3. ...
  4. private:
  5. X m_member;
  6. ...
  7. }

I'm pretty sure it's not possible, but I appreciate any feedback.

-price
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,802
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 747
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: class member that is that class

 
1
  #2
Nov 20th, 2008
>I'm pretty sure it's not possible
It's possible, but not like that. You can have a pointer or a reference to the class being defined:
  1. class X {
  2. X *m_member;
  3. };
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC