What does this error mean?


C:\Martin\Savitch\SavitchDownloads\Chapter13\Chapter13\StackFrame\stack.cpp:10:9: error: expected initializer before 'Stack'
C:\Martin\Savitch\SavitchDownloads\Chapter13\Chapter13\StackFrame\stack.cpp:9:1: error: expected initializer before 'using'
using namespace std;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  //Here is the copy constructor:
       //The definitionof the copy constructor is Self-Test Exercise 11.
  // {
        Stack::Stack(const Stack& a_stack)
   {

       if (a_stack.top == NULL)
            top = NULL;
        else
        {
            StackFramePtr temp = a_stack.top;  //temp moves
                //through the nodes from top to bottom of a_stack
            StackFramePtr end;  //Points tp end of the new stack.

            end = new StackFrame;
            end->data = temp->data;
            top = end;
            //First node created and filled with data.
            //New nodes are now added AFTER this first node.

            temp = temp->link;
            while (temp != NULL)
            {
                end->link = new StackFrame;
                end = end->link;
                end->data = temp->data;
                temp = temp->link;
            }
            end->link = NULL;
        }
 }
    //Copy Constructor 
Well since it doesn't appear that you posted the problem part of the code it is hard to tell what your issue actually is (I don't see a "using namespace std;" anywhere in your code and since the problem is before that line?).




Just a guess (as jlb said, you don't seem to be showing enough relevant code): Do you have a semi-colon after your class definition?
Okay I have found the problem and sorted it out.

Thanks everybody
Topic archived. No new replies allowed.