Friday, February 18, 2011

write a program for scope operator ( Resulation )


 // classes example
#include <iostream.h>
#include<conio.h>

class CRectangle
 {
    int x, y;
  public:
    void set_values (int,int);
    int area ()
    {
     return (x*y);
    }
};

void CRectangle::set_values (int a, int b)
 {
  x = a;
  y = b;
}

void main () 
{
  CRectangle rect;
  rect.set_values (3,4);
  cout << "area: " << rect.area();
 
}

No comments:

Post a Comment