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. error C2664 in VS2005 VC++

error C2664 in VS2005 VC++

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++visual-studio
2 Posts 2 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.
  • N Offline
    N Offline
    Nandu_77b
    wrote on last edited by
    #1

    std::list < xlong > ClientConfig:: GetHistory(int id) { .... doing something .... return 0; } When the above code is compailed in VS 2005 (VC++), following is the error error C2664: 'stlp_std::list<_Tp>::list(const stlp_std::list<_Tp> &)' : cannot convert parameter 1 from 'int' to 'const stlp_std::list<_Tp> &' with [ _Tp=xlong ] Reason: cannot convert from 'int' to 'const stlp_std::list<_Tp>' with [ _Tp=xlong ] Constructor for class 'stlp_std::list<_Tp>' is declared 'explicit' with [ _Tp=xlong ] resdata.cpp I tried to return xlong value, but still getting the same error Can any once help to fix the same

    C 1 Reply Last reply
    0
    • N Nandu_77b

      std::list < xlong > ClientConfig:: GetHistory(int id) { .... doing something .... return 0; } When the above code is compailed in VS 2005 (VC++), following is the error error C2664: 'stlp_std::list<_Tp>::list(const stlp_std::list<_Tp> &)' : cannot convert parameter 1 from 'int' to 'const stlp_std::list<_Tp> &' with [ _Tp=xlong ] Reason: cannot convert from 'int' to 'const stlp_std::list<_Tp>' with [ _Tp=xlong ] Constructor for class 'stlp_std::list<_Tp>' is declared 'explicit' with [ _Tp=xlong ] resdata.cpp I tried to return xlong value, but still getting the same error Can any once help to fix the same

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      Look at what the function is supposed to return (a std::list) and look at what you are actually returning (an integer). IF you want this to work, you either have to change the return type to long or return a std::list object form your function.

      Cédric Moonen Software developer
      Charting control [v2.0] OpenGL game tutorial in C++

      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