friend function!!!!Logical pr0blem

i have written a friend function in c++ with classes but it is not compiling.The main problem is with constructor defination as shown by the compiler i have checked my code many times but i didn't find any err0r may be there iz a logical err0r...........heLp me !!!!!

here is the code to the program

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

#include<iostream>
using namespace std;


class secret
{
//friend functi0n      
      friend void increment(secret*,int);//decLaration of Friend where secret is pointr cLass
private:
        int topsecret;

public:
       void display(){cout<<"the t0psecret iz : "<<topsecret;}
//constructor decLaration
secret();
}



//constructor definati0n
secret::secret()
{
                topsecret=100;
}

//friend function defination
void increment(secret*a,int i)//cLasss secret p0ints to a
{
        a->topsecret += i;
}


 main()
{
      secret x;
      x.display();
      increment(&x,10);
      x.display();
      system("pause");
}                         
                         
                      
                         
                         
                         
                         
                         
                         
                         
                         
                         
               
Last edited on
It could well be the missing semicolon after the class declaration;

class secret
{

} ; //<<====semicolon required after class declaration
You shall place a semicolon after the closing brace of the class definition.
0'thnxs guyz !!!!!
Topic archived. No new replies allowed.