This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Instantiating an Object

 
Rupinder Bains
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you instantiate an object??
Could somebody please kindly give me some basic examples. Thank You Very Much!
Rupes.x
 
Donald R. Cossitt
buckaroo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is an excellent tutorial here. and deeper in the same tutorial
doco
[ April 18, 2003: Message edited by: Donald R. Cossitt ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To instantiate an object, simply declare a reference and use the new keyword to create an instance for that reference:

Here I assume that you have already written the declaration for MyClass. It must include a constructor that takes no arguments. If you wish to use a constructor that takes arguments, you put them inside the () as you would with a regular function call.
Since the API already has a lot of classes declared for you, you may wish to instantiate one of them first since you wouldn't have to write all the code for a class that way.
HTH
Layne
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rupinder
How do you instantiate an object??

If it is not clear,please feel free to ask.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My class is smarter than siu's, it can write chinese with its feet:
 
Francis Siu
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rupinder
CCNA is about the network application.
Some hardware are developed by CISCO.
humm.....
Can you point out where Michael instantiate an object in the code?
If you can point out where,I think you can understand the concept of instantiate an object.
Michael is a funny bartender who always help people to answer the question, and the code is funny too,isn't it?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic