Jump to content
  • Advertisement
Sign in to follow this  
Codejack

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

This topic is 3980 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
            }
        .
        .
    };

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!