Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 10th, 2005, 04:57 AM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kerby
Default c++ concepts

whats the difference of

 
Quote:
quote:SampleClass object;
Quote:

SampleClass *object;
in which SampleClass is a class.

further, what is the difference of

Code:
object.somefunction();
from...


Code:
object->somefunction();
a journey of a thousand miles is started by taking the first step -chinese proverb
Reply With Quote
  #2 (permalink)  
Old April 10th, 2005, 11:45 PM
Authorized User
 
Join Date: Mar 2005
Posts: 58
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Alan-LB Send a message via Yahoo to Alan-LB
Default

Kerby

SampleClass object creates an object of "SampleClass" type
SampleClass *object creates a POINTER to an object of "SampleClass" type

object.somefunction() accesses "somefunction" within the object "object"
object->somefunction() dereferences a pointer to "object" to access "somefunction"

For you I think the "journey of a thousand miles" should start with the "first step" of carefully reading a few basic text books :-)

Read up on Objects and Pointers

Hope this helps

Alan

Reply With Quote
  #3 (permalink)  
Old April 16th, 2005, 11:38 AM
Authorized User
 
Join Date: Jul 2003
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to merediths
Default


 If you come from a C background think of it this way

 object->somefuntion();

 is the same as

 (*object).somefunction();

 this is, -> dereferences the pointer on the right and then calls it's somefunction() method.

Regards,
Meredith Shaebanyan

Reply With Quote
  #4 (permalink)  
Old April 16th, 2005, 11:39 PM
Authorized User
 
Join Date: Mar 2005
Posts: 58
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to Alan-LB Send a message via Yahoo to Alan-LB
Default

Which is what I said!

Alan

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Blog for QTP for certification help and concepts expertqtp VBScript 0 July 10th, 2008 01:17 AM
Basic concepts with asp.net cool_hari BOOK: Beginning ASP.NET 1.0 1 August 28th, 2006 03:41 AM
Need to Understand Big Picture Concepts newbieprogrammer Classic ASP Databases 3 February 6th, 2005 04:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.