error expected initialized before bool

This is a discussion on error expected initialized before bool within the C++ Programming forums, part of the General Programming Boards category; I got this error in the following program for line 22, and I do not know how to fix it. ...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    1

    error expected initialized before bool

    I got this error in the following program for line 22, and I do not know how to fix it.

    Code:
    // Brett Balzer
    // Converting to binary
    // 11/01/06
    
    #include <iostream>
    
    using namespace std;
    
    struct stack
    {
       int count;
       struct node *top; 
    };
    
    struct node
    {
       int data;
       struct node *next;
    };
    
    bool pushStack (struct stack *stack, int data)
    bool popStack (struct stack *stack, int &data)
    
    int main()
    {
        int number;
        int digit;
        struct stack theStack;
        struct stack *stack; 
        stack = &theStack;
    
        cout << "Enter a decimal number" << endl;
        cin >> number;
       
        while (number > 0)
        {
          digit = number % 2;
          number = number/2;
          pushOK = pushStack (stack, digit);
    
          if (pushOK == false)
          {
            cout << "Stack overflow creating digit" << endl;
            return 0;
          }
          
         }
            
        while (stack->top != NULL)
        {
          popStack (stack, digit);
          cout << digit;
        }
    
    return 0; 
    }
    
      bool pushStack (struct stack *stack, int data)
      {
        bool success;
    
        struct node *newptr;
        newptr = new struct node;
        newptr->data = data;
        newptr->next = stack->top;
        stack->top = newptr;
        stack->count = stack->count + 1;
        success = true;
        return success;
      } 
    
      bool popStack (struct stack *stack, int &data)
      {
        bool success;
    
        struct node *dltPtr;
       
        if (stack->top == NULL)
        {
          success = false;
        }
        else
        {
          dltPtr = stack->top;
          data = stack->top->data;
          stack->top = stack->top->next;
          stack->count = stack->count - 1;
          free (dltPtr);
          success = true;
         }
       }
    thank you very much!

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    add ; after function declaration
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing params between managed c++ and unmanaged c++
    By cechen in forum C++ Programming
    Replies: 11
    Last Post: 02-03-2009, 07:46 AM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  5. Need Help With an RPG Style Game
    By JayDog in forum Game Programming
    Replies: 6
    Last Post: 03-30-2003, 07:43 PM

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