What's similar to "this"?
Hi guys,
I learned how to program object-oriented using Java, and now I'm learning C++ by myself.
My doubt is: which operator plays, in C++, the same role as "this" in Java?
Considering I'd like to transcript something like this to C++:
1 2 3 4
|
public void setNumber(int value)
{
this.value = value;
}
|
Thanks for the patience.
this->value = value
1 2 3 4 5
|
public:
void setNumber(int value)
{
this->value = value;
}
|
'this' returns a pointer to the current object, that's why you have to use the -> operator.
I think I figured it out.
Gonna write and compile my program, then I tell what happened here. :)
Topic archived. No new replies allowed.