shamantou blog site

shamantou@gmail.com

导航

运算符的重载以及指针复制测试程序

// aa.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

class Fun
{
public:
    Fun()
    {
        buf = new char[10];
    }

    Fun(Fun & a)
    {
        int i=0;
    }

    ~Fun()
    {
        if(buf)
            delete []buf;
    }

    Fun operator = (Fun  c)
    {
        *this = c;
        return *this;
    }

    Fun &operator >> (int b)
    {
        return * this;
    }

    Fun & operator << (int c)
    {
        return * this;
    }


    char * buf;
};

Fun Get()
{
    Fun c;
    return c;
}

Fun & Get2()
{
    Fun c;
    return c;
}

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

   // Fun a;
    //Fun b(a);

    Fun d = Get();
    Fun e = Get2();


    d>>12;
    d<<13;

 return 0;
}

 

<< 张江地铁站c# vtk installation >>

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最近发表

Powered By Z-Blog 1.8 Arwen Build 81206 Copyright 2006-2009 | ooplab.org | shamantou@gmail.com | 沪ICP备08011244号 | Some Rights Reserved.