Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

hi.can any one tell me plz how can i use a class in another class in c++?

OpenStudy (farmdawgnation):

Classes are usually used by instantiating them. So, inside a member function somewhere you'll do something like this... ``` MyAwesomeClass* awesomeClass = new MyAwesomeClass(); ``` That will give you a pointer named awesomeClass pointing to an instance of the MyAwesomeClass. You'll want to make sure that the header file for MyAwesomeClass is also included in the same file this line is used in, or things don't work so well. :)

OpenStudy (anonymous):

http://www.cplusplus.com/doc/tutorial/inheritance/ this article will help you more in how to use a class inside another class in c++

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!