| | |
class member that is that class
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2008
Posts: 1
Reputation:
Solved Threads: 0
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,
I'm pretty sure it's not possible, but I appreciate any feedback.
-price
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,
C++ Syntax (Toggle Plain Text)
class X { ... private: X m_member; ... }
I'm pretty sure it's not possible, but I appreciate any feedback.
-price
>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:
It's possible, but not like that. You can have a pointer or a reference to the class being defined:
C++ Syntax (Toggle Plain Text)
class X { X *m_member; };
I'm here to prove you wrong.
![]() |
Similar Threads
- Inner class (Java)
- Initializing a member of a class with another const/destructor! (C++)
- Help with derived class and arithmetic in C++ (C++)
- How to get Array type members' value from a class (JSP)
- Abstract Class member function problem (C++)
- pointer to member? (C++)
- Bank account class (C++)
Other Threads in the C++ Forum
- Previous Thread: plz help me
- Next Thread: Quicksort strings?
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






