Thread: expected ';' before 's1' this s1 = s1;

  1. #1
    Registered User
    Join Date
    Nov 2015
    Posts
    119

    expected ';' before 's1' this s1 = s1;

    Good time of day you! Please, please what is wrong can be thys option so you can not? I want to know clearly.


    Code:
    enum Ts {Nul, Odyn, Dva, Tru, Tsotyry}
    
    
    class A
    {
      public:
        Ts s1;
      private:
        void poklady(Ts s1)
        {
            this s1 = s1;
        }
    
        Ts daj()
        {
            return s1;
        }
    };
    
    int main()
    {
        A a;
    
    return 0;
    }
    D:\Classes\En3\En3.cpp|12|error: expected ';' before 's1'|

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You forgot:
    • The semi-colon at the end of the enum declaration.
    • The -> in between this and s1.
    • To indent the return 0; at the end of main.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Guest
    Guest
    Code:
    enum Ts {Nul, Odyn, Dva, Tru, Tsotyry};
    
    this->s1 = s1;
    Also, it looks like you mixed up public and private.

    Damnit laserlight, do I ever need to bother

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You caught the public/private thing that I didn't!
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Nov 2015
    Posts
    119
    Big huge thanks to you! I am very grateful! Yes I strongly zatupiv. I still apologize for the carelessness and slowness.Big huge thanks to you! I am very grateful! Yes I strongly zatupiv. I still apologize for the carelessness and slowness.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 02-25-2013, 08:08 AM
  2. Expected ';' before 'else'
    By jesse in forum C Programming
    Replies: 1
    Last Post: 03-01-2012, 05:41 PM
  3. expected â)â before âeTableâ
    By philgrek in forum C Programming
    Replies: 7
    Last Post: 05-01-2011, 06:54 AM
  4. BAH! expected `;' before 'else'
    By Chef in forum C++ Programming
    Replies: 19
    Last Post: 10-03-2008, 01:37 PM
  5. expected `)' before str... help!
    By dingobiatch in forum C++ Programming
    Replies: 10
    Last Post: 05-15-2008, 10:20 AM

Tags for this Thread