Simple problem but dont know the reason..

This is a discussion on Simple problem but dont know the reason.. within the C++ Programming forums, part of the General Programming Boards category; Hi all, i'm new to c and while compiling small snippet of code on gcc its showing "expected specifier-qualifier-list before ...

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    21

    Question Simple problem but dont know the reason..

    Hi all,
    i'm new to c and while compiling small snippet of code on gcc its showing "expected specifier-qualifier-list before private" error.I'm not able to find out whats the reason causing this problem.if anyone's suggestions to solve this would be a great help.
    here is my code,

    Code:
    typedef struct
    {
      private:   // in this line i'm getting error as expected specifier-qualifier-list    
                       //before private
      int choice;
    
      public:
      void (*fun_ptr[2])();
      int add();
      int pause();
    
      void checkState(int nChoice)
      {
        if(nChoice == CONTINUE)
        {
           fun_ptr[0] = add ;
        }
    
        else if (nChoice == STOP)
        {
          fun_ptr[1] = pause ;
        }
    
        else
        {
         printf("u entered a wrong choice...exiting... ");
         exit(1);
        }
      }
    } exeState;
    
    
    int main()
    {
      //exeState s;
      printf("enter ur choice 1 to start the process of addtion...2 for pausing...");
      //scanf("%d", &s.choice);
      //s.checkState(s.choice);
      getchar();
      return 0;
    }

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,208
    Try compiling with g++ (the C++ compiler in the gnu collection), rather than gcc (which compiles C by default).

    I get legitimate errors with g++ from your code, but not the one you are reporting.
    Right 98% of the time, and don't care about the other 3%.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A simple file I/O problem
    By eecoder in forum C Programming
    Replies: 10
    Last Post: 10-16-2010, 11:00 PM
  2. Problem in simple code.
    By richdb in forum C Programming
    Replies: 6
    Last Post: 03-20-2006, 01:45 AM
  3. Problem in very simple code
    By richdb in forum C Programming
    Replies: 22
    Last Post: 01-14-2006, 08:10 PM
  4. Simple File I/O problem
    By Ignited in forum C++ Programming
    Replies: 3
    Last Post: 01-07-2006, 09:49 AM
  5. Simple Initialization Problem
    By PsyK in forum C++ Programming
    Replies: 7
    Last Post: 04-30-2004, 07:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21