Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accessing class members

Status
Not open for further replies.

nicasa

Programmer
Feb 3, 2003
54
ES
Hi there,

I would like to know when you should use the dot (.) operator as opposed to the (->) arrow operator when accessing class members ?
Should you be using the -> operator only when accessing class members for a dynamically created modal form ?

I have a class called 'utils' (within utilities.cpp) and I would like to call the functions within it from mainform.cpp. How should I instantiate it ? Should I include these lines at the top of mainform.cpp:

#include "utilities.h"
utils tools

// I can then use the tools object to call the functions

How and where can I instantiate utils dynamically:

utils tools = new utils() ???
// code here
delete tools


Thanks

bigSteve
 
The arrow operator is used for pointers:

utils *tools = new utils;
tools->myMethod();

or:

utils tools;
tools.myMethod();
 
Edit1->Text.c_str ();

does this mean that the Edit object has
been instantiated with the new operator
whereas the Text member is just declared.

Just a thought

tomcruz.net
 
Yep,

The editbox is declared as a pointer (*Edit1), you can check that in the forms header file;
The Text object is declared as "AnsiString Text" inside the Edit1 object, don't know how to make that visible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top