#include "stdafx.h"
#include "string.h"
class CBook{
public:
int m_Pages;
CBook operator+(const CBook &book)
{
CBook bk;
bk.m_Pages = m_Pages + book.m_Pages;
return bk;
}
CBook operator+(const int page)
{
CBook bk;
bk.m_Pages = m_Pages + page;
return bk;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
CBook vbBook,vcBook;
vbBook.m_Pages = 512;
vcBook.m_Pages=570;
CBook vdBook = vcBook + vbBook;
vdBook = vdBook+500;
printf("%d\n",vdBook.m_Pages);
}
C++运算符重载
最新推荐文章于 2024-09-20 00:30:00 发布