#include<iostream>
using namespace std;
class Rectangle;
class Cost
{
private:
int costRate;
public:
void setValue(int a)
{
costRate=a;
}
int totalCost(Rectangle A);
/*ekhane amra totalcost function create
korar pore bujhlam etar vetor jesob kaj korbo tar jonno rectangle
class er value er dorkar porbe,tai paramter hisabe oi class er object
pass korsi,,and function ta just declare kore rakhsi */
};
class Rectangle
{
private:
int height,width;
public:
void sets(int a,int b)
{
height = a;
width = b;
}
int area()
{
return height*width;
}
friend int Cost::totalCost(Rectangle A);
/*pura class er friend na,
just *totalcost er friend banay disi tarmane just *totalcost ei class er
jinis access korte parbe..onno keo parbe na*/
};
/* ekhane totalcost er kaj korsi,
ekta jinis dekho,totalcost silo int type,tai int disi then or nijer class er
nam disi then then scope resultaion operator then function er nam ar sate
rectangle class er object .eta amra chaile cost class er porei likhte partam,,
but,tokhon likhle kaj hoto na,,coz,compiler tokhono jane na je niche #rectangl
namer kono class ase..tai rectangle er value jeheto amra nibo
sejonno rectangle class create er porei dite hoise eta*/
int Cost::totalCost(Rectangle A)
{
return costRate*A.area();
}
int main()
{
Rectangle rct;
rct.sets(4,3);
cout<<"Area = "<<rct.area()<<endl;
Cost cst;
cst.setValue(2);
cout<<"Total cost = "<<cst.totalCost(rct);
/*totalcost jeheto rectangle class
er value nia kaj korse tai,,main function er vetor rectangle class er je
object create korsi,,seta parameter hisabe pass koira disi*/
return 0;
}
using namespace std;
class Rectangle;
class Cost
{
private:
int costRate;
public:
void setValue(int a)
{
costRate=a;
}
int totalCost(Rectangle A);
/*ekhane amra totalcost function create
korar pore bujhlam etar vetor jesob kaj korbo tar jonno rectangle
class er value er dorkar porbe,tai paramter hisabe oi class er object
pass korsi,,and function ta just declare kore rakhsi */
};
class Rectangle
{
private:
int height,width;
public:
void sets(int a,int b)
{
height = a;
width = b;
}
int area()
{
return height*width;
}
friend int Cost::totalCost(Rectangle A);
/*pura class er friend na,
just *totalcost er friend banay disi tarmane just *totalcost ei class er
jinis access korte parbe..onno keo parbe na*/
};
/* ekhane totalcost er kaj korsi,
ekta jinis dekho,totalcost silo int type,tai int disi then or nijer class er
nam disi then then scope resultaion operator then function er nam ar sate
rectangle class er object .eta amra chaile cost class er porei likhte partam,,
but,tokhon likhle kaj hoto na,,coz,compiler tokhono jane na je niche #rectangl
namer kono class ase..tai rectangle er value jeheto amra nibo
sejonno rectangle class create er porei dite hoise eta*/
int Cost::totalCost(Rectangle A)
{
return costRate*A.area();
}
int main()
{
Rectangle rct;
rct.sets(4,3);
cout<<"Area = "<<rct.area()<<endl;
Cost cst;
cst.setValue(2);
cout<<"Total cost = "<<cst.totalCost(rct);
/*totalcost jeheto rectangle class
er value nia kaj korse tai,,main function er vetor rectangle class er je
object create korsi,,seta parameter hisabe pass koira disi*/
return 0;
}
Quote: