I’m having a problem with the this pointer inside of a custom class. My code looks as follows.
class Foo{
public: void bar(); bool baz();
};
bool Foo::baz(){
return true;
}
void Foo::bar(){
bool is_baz = (*this).baz();
}
As I said above, I believe the error I’m getting (LNK2019) is coming from the this. I think it is looking for a function in a different file, which it does not find. Is there some way I can make this code work, or do I have to use some sort of work-around? If so, what should I do to work around this problem. Thank you.
Change this to
Also, this shouldn’t compile. How did you manage to get a link error?
After making this change, the linker says
undefined reference to 'main', which just means you don’t have amainfunction.