Base operand of arrow has non-pointer type ‘Foo’
From Cppsyntax
You can get the error
base operand of ‘->’ has non-pointer type ‘Foo’
if you try to use a "->" where you should be using a ".".
It is a little bit difficult to make this happen, since new Foo() returns a pointer to Foo, but you can get in this situation with references.
WRONG
class Foo
{
int i;
public: int getI()
{
return i;
}
};
class Blort
{
int one(Foo &aFoo)
{
aFoo->getI(); // aFoo is a non-pointer type here
}
};
RIGHT
class Foo
{
int i;
public: int getI()
{
return i;
}
};
class Blort
{
int one(Foo &aFoo)
{
aFoo.getI(); // use a "." instead of a "->"
}
};
