Code:
For example
class Box
{
private : int l,h,w;
public :
void get_data();
void display();
};
void Box ::display()
{
cout<<”the length of box is<<l;
cout<<”the height of box is<<h;
cout<<”the width of box is<<w;
}
void Box ::get_data()
{
cout<<”enter the length width and height of box”;
cin>>l>>h>>w;
}
In this example we have calculated the length, height and width of the box. Important thing to notice is that we have defined the function outside class in C++. This is the perfect example of Scope resolution.
Bookmarks