C++ Error...IDK what is wrong!
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 30

Thread: C++ Error...IDK what is wrong!

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    14

    Question C++ Error...IDK what is wrong!

    I am a beginner at C++...
    I made this but I don't knowwhat it means
    when the error says " error C2106: '=' : left operand must be l-value "
    can someone help me???

    ~this is the code~

    // assignment operator

    #include <iostream>
    using namespace std;

    int main ()
    {
    int a,b,c,d,e;
    2 = a;
    a = b;
    b = c;
    c = d;
    d = e;

    cout << "If A=2, E=D, D=C, C=B, and B=A then ";
    cout << "E=";
    cout << e;

    return 0;
    }

  2. #2
    Join Date
    Mar 2001
    Posts
    2,365

    Re: C++ Error...IDK what is wrong!

    this
    Code:
    2 = a;
    should be:
    Code:
    a=2;
    also this:
    Code:
    cout << "If A=2, E=D, D=C, C=B, and B=A then ";
    cout << "E=";
    cout << e;
    could be:
    Code:
    cout << "If A=2, E=D, D=C, C=B, and B=A then E=" << e << endl;
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    Mar 2009
    Posts
    14

    Exclamation Re: C++ Error...IDK what is wrong!

    it still says

    1>.\demo.cpp(9) : error C2106: '=' : left operand must be l-value

  4. #4
    Join Date
    Jun 2004
    Posts
    1,329

    Re: C++ Error...IDK what is wrong!

    Post your code
    Rate this post if it helped you.

  5. #5
    Join Date
    Mar 2009
    Posts
    14

    Talking Re: C++ Error...IDK what is wrong!

    // assignment operator

    #include <iostream>
    using namespace std;

    int main ()
    {
    int a,b,c,d,e;
    a=2;
    a = b;
    b = c;
    c = d;
    d = e;

    cout << "If A=2, E=D, D=C, C=B, and B=A then E=" << e << endl;

    return 0;
    }

  6. #6
    Join Date
    Mar 2001
    Posts
    2,365

    Re: C++ Error...IDK what is wrong!

    OK, so do you want to click the save button or should I?

    rebuild all too. In other words.... save this short program, compile it, link it and run it.

    Sometimes CG is like an old Scrubs episode.
    Last edited by ahoodin; March 29th, 2009 at 11:24 PM.
    ahoodin
    To keep the plot moving, that's why.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center