// AssignmentOperatorTest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include <typeinfo>

using namespace std;

class point
{
public:
point(float x=0.0,float y=0.0)
{}
inline virtual point& operator =(const point &p);
protected:
float _x,_y;
};

inline point& point::operator =(const point &p)
{
cout<<"i am point"<<endl;
_x=p._x;//protected
_y=p._y;
return *this;
}

class point3d:public point
{
public:
inline virtual point3d& operator =(const point3d &p)
{
cout<<"i am point3d"<<endl;
return *this;
}
};



int _tmain(int argc, _TCHAR* argv[])
{
point3d pt3;

point &pp=pt3;

pp.operator =(pt3);

cout<<typeid(pp).name()<<endl;

getchar();

return 0;
}

相关文章:

  • 2022-01-10
  • 2022-12-23
  • 2021-09-03
  • 2021-07-04
  • 2021-07-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-31
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
相关资源
相似解决方案