I am getting an error I do not understand. There was even a similar question asked on SO that I开发者_运维百科 found, but the fix given is already in my code.
I am getting an error in this line:
ForestNode<NODETYPE> foo = new ForestNode<NODETYPE> ForestNode(bar);
that reads :
\project 4\forest.h|85|error: expected ',' or ';' before 'ForestNode'
My class forestnode is defindes as such:
template<typename NODETYPE> class Forest;
template<typename NODETYPE> class ForestNode
{
    friend class Forest<NODETYPE>;
    public:
        ForestNode( const NODETYPE &);
        ~ForestNode();
        NODETYPE getTag() const;
    private:
        NODETYPE tag;
        ForestNode<NODETYPE> *leftChild;
        ForestNode<NODETYPE> *sibling;
};
Any ideas?
You have the type name twice in the constructor call, try:
ForestNode<NODETYPE> foo = new ForestNode<NODETYPE>(bar);
Besides having 2 constructors on one line, you can not allocate the pointer to the variable. You either have to do this :
ForestNode *foo = new ForestNode;
or do this :
ForestNode<NODETYPE> foo;
or this :
ForestNode<NODETYPE> bar;
ForestNode<NODETYPE> foo( bar );
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论