bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_2 / eduincs / pgrm_015.cpp

pgrm_015.cpp (638B)


      1 /* `friend` function */
      2 
      3 #include<iostream> 
      4 using namespace std;
      5 class rectangle {
      6 	int length, breadth;
      7 public: 
      8 	rectangle() {};
      9 	rectangle(int l, int b) {length = l; breadth = b;}
     10 
     11 	int area() {
     12 		return length * breadth;
     13 	}
     14 	friend rectangle double_dimen(const rectangle &);
     15 };
     16 
     17 rectangle double_dimen(const rectangle &param) {
     18 	rectangle res;
     19 	res.length = param.length * 2;
     20 	res.breadth = param.breadth * 2;
     21 	return res;
     22 }
     23 
     24 int main() {
     25 	rectangle obj;
     26 	rectangle obj2(2, 3);
     27 	cout << "Area of obj2: " << obj2.area() << endl;
     28 	obj = double_dimen(obj2);
     29 	cout << "After magnify: \nArea of obj: " << obj.area() << endl;
     30 	return 0;
     31 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror