c++——结构与指针 类与指针

//结构与指针
struct MyPoint
{
    int x, y;
};
//类与指针
class CMyButton
{
    int x, y;
    char isType;
public:
    void setButtonDown(char it);
    char getButtonDown()const { return isType; }
};
void CMyButton::setButtonDown(char it)
{
    isType = it;
}

void main()
{
    MyPoint *pt;
    MyPoint pos = { 1, 2 };
    pt = &pos;
    pt->x = 10;
    pt->y = 20;

    CMyButton mb;
    CMyButton*pmb;
    pmb = &mb;
    pmb->setButtonDown('T');
    pmb->getButtonDown();
}

 

posted @ 2017-10-01 22:20  千面鬼手大人  阅读(209)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css