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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual C++ Pointers to Classes problem

Status
Not open for further replies.

jtax

Programmer
Jan 9, 2003
1
0
0
US
I created a Class C with a member variable: someString. And a function: string getString()
In my main() i have:

C object( "hello" );
C* pointer = &object;
cout << pointer->getString() << endl;

The problem is that it's giving me gibberish. I was wondering if i needed to add a template specialization for pointers of Class C, i.e. template <> Class C<void*> or something like that.

Any suggestions are appreciated,
jtax
 
If getString() is returning a std::string object, I think you have to write &quot;pointer->getString().c_str()&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top