class 初始化操作

本文介绍了C++中类CP2的构造函数、属性和赋值操作,以及CLine类的成员变量和方法,如CLine对象的坐标和线条操作。同时提到了CAge类作为CMDTarget的实现,以及内联函数的使用。焦点在于面向对象的设计和基础编程概念。
摘要由CSDN通过智能技术生成

class CP2  
{
public:
    CP2();
    CP2(float fx , float fy ): x(fx) ,y(fy),w(1.0f){}
    virtual ~CP2();
public:
    float x ;
    float y ;
    float w ;
public:
    CP2&  operator= (const CP2 & p)
    {
        this->x = p.x ;
        this->y = p.y ;
        this->w = p.w ;
    }
};


#include "P2.h"

class CLine  
{
public:
    CLine();
    virtual ~CLine();
public:

    CP2 m_ptOrg ;
    CP2 m_ptEnd ;
    CP2 P[1];

public:
    void SetCLine()
    {

    }
    void ReadCP2()
    {

    }

    void Draw(CDC* pDC)
    {

    }
};

class CAge : public CCmdTarget
{
public:        
    CAge();
    virtual ~CAge() ;
    CAge(UINT in_val) : val(in_val) {}
private:
    UINT val ;    
public:
    UINT GetValue()   {return val ;}
//声明为内联函数要放在类的外面
    friend bool operator == (const CAge & , const CAge &) ;
};
//这个内联定义要放在类的外面
    inline bool operator == (const CAge & a , const CAge & b ) 
    {return  a.val == b.val ;}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值