Static Data Member Assignment Help

Assignment Help: >> Classes and Objects - Static Data Member

Static data member

Static data members are data objects which are general to all the objects of a class. They exist just once in all object of this class. A static member is used in information which is usually accessible. Given property of the static data members might lead a person to think in which static members are essentially global variables. This is not true. A Static member could be any one of the groups: public, private or protected, but it is not global data.

Example:

// static data member

# include<iostream.h>

class example

{

private:

static int counter;

public:

};

void display( );

int example::counter =100;

void example::display ( )

{

int i;

for(i =0; i<=10; ++I)

counter = counter+1;

}

cout<<"sum of the counter value ="<<counter cout<< endl;

}void main( )

{

example obj1;

int i;

for(i = 0; i <=3; ++i)

{

cout<< "count="<<I+1<<endl;

obj.display( );

cout<<endl;

}

output is

count = 1

sum of counter value = 155

count = 2

sum of counter value = 210

count = 3

sum of counter value = 265

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd