C++ 调用成员函数

C++ 调用成员函数,c++,class,object,member-function-pointers,C++,Class,Object,Member Function Pointers,我不知道如何从main调用类成员函数。我想用一个poly对象作为其隐式参数调用printPoly 以下是类定义: class poly { private: Node *start; public: poly(Node *head) /*constructor function*/ { start = head; } void printPoly(); //->Poly *polyObj would be the impl

我不知道如何从main调用类成员函数。我想用一个poly对象作为其隐式参数调用printPoly

以下是类定义:

class poly
{
private:
    Node *start;    
public:
    poly(Node *head)  /*constructor function*/
    {
        start = head;
    }

    void printPoly(); //->Poly *polyObj would be the implicit parameter??
};

void poly :: printPoly()
{
    //....
}
以下是呼叫代码:

poly *polyObj;
polyObj = processPoly(polynomial); // processPoly is a function that returns a poly *
polyObj.printPoly(); // THIS IS WHERE THE PROBLEM IS

现在,我想用我刚刚创建的polyBj调用printPoly。

在调用函数之前,必须取消对指针的引用。指针包含对象的地址,取消引用返回对象。因此:

(*polyObj).printPoly();
然而,这通常被缩短为:

polyObj->printPoly();

在调用函数之前,必须取消对指针的引用。指针包含对象的地址,取消引用返回对象。因此:

(*polyObj).printPoly();
然而,这通常被缩短为:

polyObj->printPoly();