0

if I wanted to do for example this

class MyClass{
     float x,y;
     void SomeFunction()
};
void MyClass::SomeFunction(){
     MyClass A = this;//????
}

How would I do that? I have virtually no experience with pointers so please help me out.
I basically want to make the new class I am creating within the class equal to the parent class or what ever you would call it. I tried puting * and & in different places but always got an error.

Edited by noey699: said function but ment class

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by noey699
0
class Myclass{
      float x,y;
      void some_function();
      };
      
void Myclass::some_function(){
     Myclass* a = this;
     }
0

Ok that worked but I got one more problem. I need to return the class afterwords. How do I return a pointer?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.