give solution of this problem

this code generate 4-errors when i build this program. please give solution to this problem
#include<iostream>
using namespace std;
class SMember
{
static int a;
public:
static void get()
{
a=40;

}
static void show()
{
cout<<"a = "<<a<<endl;
}
};
static void main()
{
SMember::get();
SMember::show();
}
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
#include<iostream>
using namespace std;

class SMember
{
    private:
    static int a;

    public:
    static void get()
    {
        a=40;
    }

    static void show()
    {
        cout<<"a = "<<a<<endl;
    }
};

//you also have to globally declare
//the static variable
int SMember::a;

//and use int main
int main()
{
    SMember::get();
    SMember::show();

    cin.get();
    return 0;
}
Last edited on
Topic archived. No new replies allowed.