![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Dec 2004
Posts: 3
Rep Power: 0
![]() |
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: |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Nov 2004
Posts: 4
Rep Power: 0
![]() |
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.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Dec 2004
Posts: 3
Rep Power: 0
![]() |
Thanks! Now i understand. I've only seen & used with classes, so I should've figured it was goin to be something like that. ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|