Программы на C++. Форум разработчиков
-
Anonymous
Как применить перегрузку оператора для унарного постфиксного оператора
Сообщение
Anonymous »
ниже приведен код перегрузки оператора для унарного оператора ++
Код: Выделить всё
#include
using namespace std;
class Distance {
private:
int feet; // 0 to infinite
int inches; // 0 to 12
public:
// required constructors
Distance() {
feet = 0;
inches = 0;
}
Distance(int f, int i) {
feet = f;
inches = i;
}
// method to display distance
void displayDistance() {
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/71317624/how-to-apply-operator-overloading-for-unary-postfix-operator[/url]
1763079754
Anonymous
ниже приведен код перегрузки оператора для унарного оператора ++
[code]#include
using namespace std;
class Distance {
private:
int feet; // 0 to infinite
int inches; // 0 to 12
public:
// required constructors
Distance() {
feet = 0;
inches = 0;
}
Distance(int f, int i) {
feet = f;
inches = i;
}
// method to display distance
void displayDistance() {
cout
Подробнее здесь: [url]https://stackoverflow.com/questions/71317624/how-to-apply-operator-overloading-for-unary-postfix-operator[/url]