源码
// 10OpOverloading.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
class Account
{
int balance;
public:
Account():balance(0){}
void Save(int money)
{
balance += money;
}
Account& operator+(int money)
{
balance += money;
}
};
int main(int argc, char* argv[])
{
Account a;
a.Save(100);
a = a+100;
//问题:什么是运算符重载?哪些运算符不能够全局重载?
return 0;
}
问题:什么是运算符重载?哪些运算符不能够全局重载?
运算符重载是重载运算符的功能。不能重载的运算符有:: 、.*、.、?: