Главная »
2019 » Октябрь » 22 » Классы 4 Дружественные функции
10:07 Классы 4 Дружественные функции |
#include <iostream>
using namespace std;
class b;
class a{
friend int sum(a,b);
private:
int i;
public:
void set() {
cout<<"Vvedite i "; cin>>i;
}
};
class b{
friend int sum(a,b);
private:
int j;
public:
void set() {
cout<<"Vvedite j "; cin>>j;
}
};
int sum(a first, b second){
return first.i+second.j;
}
int main(){
a first;
b second;
first.set();
second.set();
cout<<sum(first,second)<<endl;
system("PAUSE");
}
|
Просмотров: 187 |
Добавил: denjes
| Рейтинг: 0.0/0 |