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
T

Twinsen724

@Twinsen724
About
Posts
5
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Is it a lvalue?
    T Twinsen724

    Hi Jay, Your remark is very helpful! ;) Best regards Twinsen

    C / C++ / MFC help question

  • Is it a lvalue?
    T Twinsen724

    Hi Jay, I use cl.exe of MS VC++6.0 IDE. Best regards Twinsen

    C / C++ / MFC help question

  • Is it a lvalue?
    T Twinsen724

    Hi Rage, Thank you for your reply! I compiled your code, but it works. I guess the problem is the return value of "X get(X)". It generates const by the compiler because it is a temporary. But I don't write it as "const X get(X)" and I restore it as a general reference, so no error displayed while compiling. Hope my guess is right. Thanks anyway! Best regards Twinsen -- modified at 21:46 Thursday 30th March, 2006

    C / C++ / MFC help question

  • Is it a lvalue?
    T Twinsen724

    Hi Jay, Thanks to your reply~ Your remark is reasonable. I think the key point of the problem is that what get() returns is a temporary object which is default const by the compiler, so I think it isn't a lvalue. Your reply makes me trust that the compiler in fact generates a const temporary, but because the return type is "X" other than "const X", a implicit conversion happened so that the complier didn't complain when compiling the file. Am I right? Thanks a lot! Best regards Twinsen -- modified at 21:36 Thursday 30th March, 2006

    C / C++ / MFC help question

  • Is it a lvalue?
    T Twinsen724

    Hi, I have a problem about this routine: #include < iostream > using namespace std; class X { public: X() { cout << "c1" << endl; } X(int i):i(i) { cout << "c2" << endl; } X(const X& x) { cout << "c3" << endl; } int i; }; X get(X i) { X x(i); return x; } int main() { X& x = get(1); x.i++; return 0; } I think after I call get(1), a temporary object X should be created, it's const so cannot be a lvalue whose value is changeable. but the code above could be compiled without any complain. Could you kindly tell me where am I wrong? Thank you very much! Best regards -- modified at 0:29 Thursday 30th March, 2006

    C / C++ / MFC help question
  • Login

  • Don't have an account? Register

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