Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 13th, 2004, 8:11 PM   #1
amado
Newbie
 
Join Date: Dec 2004
Posts: 3
Rep Power: 0 amado is on a distinguished road
I've known C for about a 2 years now and I've gotten pretty good at it, now I'm wanting to learn C++ and there is something that is not very clear to me. All of the code I've seen that passes a pointer to a class object to a function uses this format:

class mClass { ... }

void foo(mClass& X);

In C, passing a structure would be like this:

struct blah { ... }

void foo(blah *X);

What is the difference in passing object pointers or what does the operator "&" do? in C it means "address of" ? I'm kind of confused. :unsure:
amado is offline   Reply With Quote
Old Dec 13th, 2004, 8:16 PM   #2
ashgromnies
Newbie
 
Join Date: Nov 2004
Posts: 4
Rep Power: 0 ashgromnies is on a distinguished road
The & means you are passing by reference... therefore the receiving function has absolute control over the memory location and can do whatever to it. * means address of the object it's pointing at.
ashgromnies is offline   Reply With Quote
Old Dec 13th, 2004, 8:23 PM   #3
amado
Newbie
 
Join Date: Dec 2004
Posts: 3
Rep Power: 0 amado is on a distinguished road
Thanks! Now i understand. I've only seen & used with classes, so I should've figured it was goin to be something like that.
amado is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC