Friday 23 April 2021

Scope Resolution Operator in C++ Qus: 4

 #include<iostream.h>

#include<conio.h>

class A

{

public:

int x;

static int y;

A()

{

x=5;

y=10;

}

void show()

{

y=12;

}

static void display()

{

cout<<"Hello"<<endl;

}

};

int A:: y=15;


int main()

{

clrscr();

cout<<A::y<<endl;

A ob;

cout<<ob.x<<endl;

cout<<A::y<<endl;

ob.show();

cout<<ob.y<<endl;

ob.display();

A::display();

getch();

return 0;

}

No comments:

Post a Comment