class object pointer access methods?

I am writing code and I am using a pointer to point to an object of a class I created. I want to have this pointer run a method, but I am getting an error of:
request for member 'ClassMethod' in 'ptr', which is of non-class type

Essentially my main code (at the error) is this:
1
2
void MyFunction(Object * ptr)
{*ptr.ClassMethod(true);}

and the method in the class:
1
2
void Object::ClassMethod(bool var)
{/*execute code*/}

How would do this?
Try:
1
2
3
ptr->ClassMethod
//or more verbose:
(*ptr).ClassMethod
Your error is happening due to the order of operations. The member access is coming before the dereference so you're trying to do the member access on the pointer.

Some brackets will help:

(*ptr).ClassMethod(true);

(or equivalently)

ptr->ClassMethod(true);
Thanks, that worked.
Topic archived. No new replies allowed.