0
How can i run this?
#include<iostream.h> #include<conio.h> int gvar=20; void display(); class demo { public: int i; void show() { cout<<"inside the class demo"<<endl; } }; void main() { int p=10; clrscr(); demo obj; obj.i=40; obj.show(); cout<<"local variable"<<p<<endl; cout<<"global variable"<<gvar<<endl; cout<<"class variable"<<obj.i<<endl; } void display() { cout<<"user defined function defination"<<endl; getch(); }
2 Respuestas
+ 1
Something like this can run in Sololearn's Code Playground.
#include <iostream>
using namespace std;
int gvar=20;
void display();
class demo
{
public:
int i;
void show()
{
cout<<"inside the class demo"<<endl;
}
};
int main()
{
int p=10;
demo obj;
obj.i=40;
obj.show();
cout<<"local variable"<<p<<endl;
cout<<"global variable"<<gvar<<endl;
cout<<"class variable"<<obj.i<<endl;
return 0;
}
void display()
{
cout<<"user defined function defination"<<endl;
}