Free Republic
Browse · Search
General/Chat
Topics · Post Article

To: tioga
It's a common word in the computer science realm. As in: How do I instantiate an object within an object?
8 posted on 07/06/2017 5:27:33 AM PDT by pa_dweller (President Donald Trump, President Donald Trump. Because I know you like seeing it.)
[ Post Reply | Private Reply | To 1 | View Replies ]


To: pa_dweller
It's a common word in the computer science realm.

Question at the link provided: "Heyy what im trying to do in this program is create a new instance of another class within a class. Im having trouble doing so, iv already tried defining the 'Weapon' class within the 'Enemy' class through its constructor, didnt quite work though... I could play around with it for hours on end until i figure it out, i'd rather not though. Iv provided my code below. Can anyone help?"

Answer: "Just put the object in your class like you do with any other member var, and put its ctor arguments in the initializer list of your constructor."

Some top rate instantiation going on there.

9 posted on 07/06/2017 5:40:26 AM PDT by Ahithophel (Communication is an art form susceptible to technical failures)
[ Post Reply | Private Reply | To 8 | View Replies ]

Free Republic
Browse · Search
General/Chat
Topics · Post Article


FreeRepublic, LLC, PO BOX 9771, FRESNO, CA 93794
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson