// Justin C. Miller
// 3-30-2001
// made for: http://www.geocities.com/neonprimetime.geo/index.html
// made on: Microsoft Visual C++ 6.0
// Title: this
#include
class Rectangle{
private:
int length ;
int width ;
public:
Rectangle(){
length = 1 ;
width = 1 ;
}
// Rectangle(int l, int w){
// length = l ;
// width = w ;
// }
// this keyword is a pointer to the object you are within
// thus the following constructor works similar to the one
// above
Rectangle(int l, int w){
this->length = l ;
this->width = w ;
}
int getWidth() {return width;}
int getLength() {return length;}
int Area(){ return length * width ;}
int Perimeter(){return 2*length + 2*width ;}
// the this keyword is a pointer to the object
// you are within
void Print(){
cout << "Length=" << this->getLength() << endl ;
// same as
// cout << "Length=" << getLength() << endl ;
cout << "Width=" << this->getWidth() << endl ;
// same as
// cout << "Width=" << getWidth() << endl ;
cout << "Area=" << this->Area() << endl ;
// same as
// cout << "Area=" << Area() << endl ;
cout << "Perimeter=" << this->Perimeter() << endl ;
// same as
// cout << "Perimeter=" << Perimeter() << endl ;
}
};
int main(){
Rectangle a, b(5,6) ;
a.Print() ;
b.Print() ;
return 0 ;
}
               (
geocities.com/neonprimetime.geo/cpp)                   (
geocities.com/neonprimetime.geo)