Code:
For example
class Box
{
private : int l,h,w;
public :
void get_data()
{
cout<<”enter the length width and height of box”;
cin>>l>>h>>w;
}
void display()
{
cout<<”the length of box is<<l;
cout<<”the height of box is<<h;
cout<<”the width of box is<<w;
}
};
main ()
{
Box b1,b2;
b1.get_data();
b2.get_data();
b1.display();
b2.display();
}
This is an example of Global class. Over here you will find that global class is defined outside the function where as previously in local class it was defined in the function itself. This is only the major difference between the local and global class. I think you might be now cleared with the concept of global class and local class.
Bookmarks