Vorislik sinfiga misol
Friend class1.
// Ikki qiymadan minimumini chiqariah
#include
using namespace std;
class qiymat{
int a, b;
public:
qiymat(int i ,int j) {a=i; b=j;}
friend class Min;
};
class Min{
public:
int min(qiymat x) {return x.a
int main(){
qiymat ob(88,77);
Min m;
cout<
return 0;}
2.// Ikki qiymatning yig`indisini chiqarish
#include
using namespace std;
class myclass{
int a, b;
public:
friend int sum(myclass x);
void set_ab(int i, int j) {a=i; b=j;}
};
int sum(myclass x){
return x.a+x.b;};
int main(){
myclass n;
n.set_ab(77,88);
cout<
return 0;}
Do'stlaringiz bilan baham: |