我有一个具有公共成员函数的 Node 对象。当我在这种情况下有一个指针(或双指针)指向原始对象时,如何调用成员函数?
这是 Node 类中的成员函数:
class Node {
public:
...
int setMarked();
...
private:
...
int marked;
...
};
这是我试图调用该函数的地方:
Node **s;
s = &startNode; //startNode is the original pointer to the Node I want to "mark"
q.push(**s); //this is a little unrelated, but showing that it does work to push the original object onto the queue.
**s.setMarked(); //This is where I am getting the error and where most of the question lies.
为了以防万一, .setMarked() 函数如下所示:
int Node::setMarked() {
marked = 1;
return marked;
}