C++结构体和类

#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 
", tt->getTest());
    printf("%d 
", tt->i);
    getchar();
    return 0;
}
struct和class好像没什么太大的区别,详见请阅读《C++编程思想》
原文地址:https://www.cnblogs.com/flashbird/p/4463368.html