friend class

plz help me to guess out what is wrong in the following code....
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
33
34
35
36
37
38
#include<iostream>
#include<conio.h>
using namespace std;
class square;
class rectangle
{
    int width,height;
    public:
        void setvalues(square);
        int area()
        {
            return(width*height);
        }
}
class square
{
    int side;
    public:
        square(int);
        
        friend class rectangle;   
};
          void rectangle::setvalues(square x)
            {
                width=x.side;
                height=x.side;
            }
            square::square(int y)
            {
                side=y;}
 int main()
 {
        square mysq(4);
        rectangle rect;
        rect.setvalues(mysq);
        cout<<rect.area();
        getch();
    } 

i am getting an error as multiple types in one declaration in the 22nd line...
i am using wxdev c++on windows 7..
Any help or guesses is appreciated...
Last edited on
Look at line 14.
i am such a big moron....couldn't even figure out such a silly thing.
anyways thanks a lot
Don't worry about it, I doubt there's a programmer out there that hasn't forgotten to drop a semicolon at the end of their class or structure.

Did your compiler not error on line 14? It's strange because my compiler usually catches that and will error on it, but I have Visual Studios so that could be a factor, though it would still seem to be a relatively common error to catch.
Topic archived. No new replies allowed.