Advertisement

C++ template code not compiling on linux (const_iterator)

Started by December 29, 2007 03:28 PM
1 comment, last by Codejack 16 years, 10 months ago
Hi Guys, I am having a problem getting some C++ code to compile on Linux. The following code compiles fine on Visual Studio 2005 on my Windows XP box but not on Code::Blocks on my Ubuntu desktop 7.10 system. I have bolded the part that seems to be causing the problem. The error message given is "error: expected ';' before 'curEdge'" Can anyone help?

template <class node_type, class edge_type>
    class CSparseGraph
    {
        public:
            typedef edge_type EdgeType;
            typedef node_type NodeType;
            typedef std::vector<node_type> NodeVector;
            typedef std::list<edge_type> EdgeList;
            typedef std::vector<EdgeList> EdgeListVector;

        private:
            NodeVector m_Nodes;
            EdgeListVector m_Edges;
            bool m_Digraph;
            int m_NextNodeIndex;

        public:
            CSparseGraph(bool Digraph):m_NextNodeIndex(0),m_Digraph(Digraph){ }

            .
            .

            int NumEdges() const
            {
                int tot = 0;

                for (EdgeListVector::const_iterator curEdge = m_Edges.begin(); curEdge != m_Edges.end(); curEdge++)
                {
                    tot += curEdge->size();
                }

                return tot;
            }
        .
        .
    };
It should probably be:
typename EdgeListVector::const_iterator
Advertisement
Quote: Original post by SiCrane
It should probably be:
typename EdgeListVector::const_iterator

Wow, that worked! Thank you for looking at my problem SiCrane!

For posterity, I found this article after I updated my code which describes the issue.

This topic is closed to new replies.

Advertisement