#include <iostream>
using namespace std;
class Foo {
public:
int bar;
};
void increment_copy(Foo object) {
object.bar ++;
}
void increment_pointer(Foo* object) {
object.bar ++;
}
int main() {
Foo object;
object.bar = 7;
cout << object.bar << endl;
increment_copy(object);
cout << object.bar << endl;
increment_pointer(&object);
cout << object.bar << endl;
return 0;
}
class Name_changer
def change_name(player)
player.change_name_to("Johnny Starr")
end
end
j = Player.new
n = Name_changer.new
n.change_name( j )
player.level = player.level + 1;
player.level_up()
I know i've started a ton of threads with questions about C and C++, so i thought i might save
the forum some sql records and create a thread about the questions i have as they come up.
QUESTION: 1
I probably made the mistake of learning C before i messed with C++, so i'm having a hard time wrapping
my brain around the purpose of creating a pointer to a class?
I took this from www.cplusplus.com
Could someone explain the difference or need of using a pointer instead of just using the object?