4.5.6函数运算符调用
#include <iostream>
using namespace std;
#include<string>
class myprint
{
public:
void operator()(string test)
{
cout << test << endl;
}
};
void test01()
{
myprint mypri;
mypri("asasaassaa");
}
int main4_5_6()
{
test01();
system("pause");
return 0;
}
4.5.5关系运算符
#include <iostream>
using namespace std;
class person
{
public:
person(string name, int age)
{
m_name = name;
m_age = age;
}
bool operator==(person &p)
{
if (this->m_name == p.m_name&&this->m_age == p.m_age)
{
return true;
}
return false;
}
string m_name;
int m_age;
};
void test01()
{
person p1("tom", 18);
person p2("tom", 18);
if (p1 == p2)
{
cout << "sss" << endl;
}
}
int main4_5_5()
{
test01();
system("pause");
return 0;
}