Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Convertin from c++ 6 to Visual studio C++ 10

Convertin from c++ 6 to Visual studio C++ 10

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studiotutorial
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mamoony
    wrote on last edited by
    #1

    Hi I am new in c++. Recently I am converting a C++ project to Visual Studio 10 c++ . I am getting an error.

    error C2664: 'std::_Vector_iterator<_Myvec>::_Vector_iterator(const std::_Vector_iterator<_Myvec> &)' : cannot convert parameter 1 from 'int' to 'const std::_Vector_iterator<_Myvec> &'

    The code is:

    XNodes::iterator _tagXMLNode::GetChildIterator( LPXNode node )
    {
    XNodes::iterator it = childs.begin();
    for( ; it != childs.end() ; ++(it) )
    {
    if( *it == node )
    return it;
    }
    return NULL; //error is in here
    }

    How to fix it? Thanks in advance, Sai

    C 1 Reply Last reply
    0
    • M mamoony

      Hi I am new in c++. Recently I am converting a C++ project to Visual Studio 10 c++ . I am getting an error.

      error C2664: 'std::_Vector_iterator<_Myvec>::_Vector_iterator(const std::_Vector_iterator<_Myvec> &)' : cannot convert parameter 1 from 'int' to 'const std::_Vector_iterator<_Myvec> &'

      The code is:

      XNodes::iterator _tagXMLNode::GetChildIterator( LPXNode node )
      {
      XNodes::iterator it = childs.begin();
      for( ; it != childs.end() ; ++(it) )
      {
      if( *it == node )
      return it;
      }
      return NULL; //error is in here
      }

      How to fix it? Thanks in advance, Sai

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Change from

      Quote:

      return NULL; //error is in here

      to

      return it;

      Veni, vidi, vici.

      M 1 Reply Last reply
      0
      • C CPallini

        Change from

        Quote:

        return NULL; //error is in here

        to

        return it;

        Veni, vidi, vici.

        M Offline
        M Offline
        mamoony
        wrote on last edited by
        #3

        Hi, Thanks. But the logic of the code is if the node matches wuth it then return it else return nothing. Thanks, Saimanti

        C 1 Reply Last reply
        0
        • M mamoony

          Hi, Thanks. But the logic of the code is if the node matches wuth it then return it else return nothing. Thanks, Saimanti

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          The 'return it' I suggested returns childs.end() that is the past-the-end iterator (a 'typed' NULL, roughly speaking).

          Veni, vidi, vici.

          M 1 Reply Last reply
          0
          • C CPallini

            The 'return it' I suggested returns childs.end() that is the past-the-end iterator (a 'typed' NULL, roughly speaking).

            Veni, vidi, vici.

            M Offline
            M Offline
            mamoony
            wrote on last edited by
            #5

            Thank you. It worked. But now it is giving another error..

            error C2451: conditional expression of type 'std::_Vector_iterator<_Myvec>' is illegal

            The code below:

            bool _tagXMLNode::RemoveChild( LPXNode node )
            {
            XNodes::iterator it = GetChildIterator( node );
            if( it ) //error is here
            {
            delete *it;
            childs.erase( it );
            return true;
            }
            return false;
            }

            Thank in advance, Saimanti

            M J 2 Replies Last reply
            0
            • M mamoony

              Thank you. It worked. But now it is giving another error..

              error C2451: conditional expression of type 'std::_Vector_iterator<_Myvec>' is illegal

              The code below:

              bool _tagXMLNode::RemoveChild( LPXNode node )
              {
              XNodes::iterator it = GetChildIterator( node );
              if( it ) //error is here
              {
              delete *it;
              childs.erase( it );
              return true;
              }
              return false;
              }

              Thank in advance, Saimanti

              M Offline
              M Offline
              mamoony
              wrote on last edited by
              #6

              I did..

              bool _tagXMLNode::RemoveChild( LPXNode node )
              {
              XNodes::iterator it = GetChildIterator( node );
              if( it != childs.end())
              {
              delete *it;
              childs.erase( it );
              return true;
              }
              return false;
              }

              Is this right? Thanks, Saimanti

              C 1 Reply Last reply
              0
              • M mamoony

                I did..

                bool _tagXMLNode::RemoveChild( LPXNode node )
                {
                XNodes::iterator it = GetChildIterator( node );
                if( it != childs.end())
                {
                delete *it;
                childs.erase( it );
                return true;
                }
                return false;
                }

                Is this right? Thanks, Saimanti

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #7

                It should be correct.

                Veni, vidi, vici.

                M 1 Reply Last reply
                0
                • C CPallini

                  It should be correct.

                  Veni, vidi, vici.

                  M Offline
                  M Offline
                  mamoony
                  wrote on last edited by
                  #8

                  Thank you very much... Saimanti

                  1 Reply Last reply
                  0
                  • M mamoony

                    Thank you. It worked. But now it is giving another error..

                    error C2451: conditional expression of type 'std::_Vector_iterator<_Myvec>' is illegal

                    The code below:

                    bool _tagXMLNode::RemoveChild( LPXNode node )
                    {
                    XNodes::iterator it = GetChildIterator( node );
                    if( it ) //error is here
                    {
                    delete *it;
                    childs.erase( it );
                    return true;
                    }
                    return false;
                    }

                    Thank in advance, Saimanti

                    J Offline
                    J Offline
                    JackDingler
                    wrote on last edited by
                    #9

                    bool _tagXMLNode::RemoveChild( LPXNode node )
                    {
                    XNodes::iterator it = GetChildIterator( node );
                    if( it != childs.end() ) // Fixed it
                    {
                    delete *it;
                    childs.erase( it );
                    return true;
                    }
                    return false;
                    }

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups