🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

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

Started by
1 comment, last by Codejack 16 years, 6 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;
            }
        .
        .
    };
Advertisement
It should probably be:
typename EdgeListVector::const_iterator
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