mujeeb3108
Answered On : Nov 15th, 2011
Static variable: A value assigned to a static variable will be shared across all instances of the class.
Instance variable: A value assigned to an instance variable is local to that object and it will be different for each instance of that class.
Login to rate this answer.
mujeeb3108
Answered On : Nov 15th, 2011
Static variable: A value assigned to a static variable will be shared across all instances of the class.
Instance variable: Each instance variable will hold different value that will not be share among instances,
On the other hand an instance variable may have different values across every different instance of the class.
Code
class MyClass
{
int myInstance;
static int myStatic=10;
public:
putvalues(int my)
{
myInstance = my;
}
getvalues()
{
printf("myInstance %d",myInstance);
printf("myStatic %d",myStatic);
};
main()
{
MyClass a,b;
a.putvalues(100);
b.putvalues(200);
a.getvalues();
b.getvalues();
}
output:
a:
myInstance 100
myStatic 10
b:
myInstance 200
myStatic 10

1 User has rated as useful.
Login to rate this answer.
pavani
Answered On : Feb 18th, 2012
Where I have to write clrscr() in a CPP programme
Login to rate this answer.