首页 > 编程语言 > 详细

C++结构体和类

时间:2015-04-28 17:42:19      阅读:231      评论:0      收藏:0      [点我收藏+]
#include "stdafx.h"
using namespace std;

class Test
{
public:
    int i;

    int getTest()
    {
        return i;
    }
};

typedef struct _tag_Test
{
    int i;
} TEST;

int _tmain(int argc, _TCHAR* argv[])
{
    TEST* t = new TEST;
    t->i = 1;

    Test* tt = (Test*)t;

    printf("%d \n", tt->getTest());
    printf("%d \n", tt->i);
    getchar();
    return 0;
}
struct和class好像没什么太大的区别,详见请阅读《C++编程思想》

C++结构体和类

原文:http://www.cnblogs.com/flashbird/p/4463368.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!