Chinaunix首页 | 论坛 | 博客
  • 博客访问: 40316
  • 博文数量: 32
  • 博客积分: 1326
  • 博客等级: 中尉
  • 技术积分: 330
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-25 18:13
文章分类

全部博文(32)

文章存档

2010年(32)

我的朋友
最近访客

分类: WINDOWS

2010-07-03 23:43:08

#include "stdafx.h"
#include <memory.h>

typedef struct tagTest
{
    int a;
    int b;
    int c;
}TEST;

class CParentTest
{
public:
    int GetC(void){return c;};
protected:
private:
    int c;
};

class CTest : public CParentTest
{
public:
    int GetA(void){return a;};
    int GetB(void){return b;};    
protected:
private:
    int a;
    int b;    
};

int main(int argc, char* argv[])
{
    TEST oTest;
    memset(&oTest, 0, sizeof(TEST));
    oTest.a = 10;
    oTest.b = 20;
    oTest.c = 30;

    CTest* pCTest = (CTest*)&oTest;
    int a = pCTest->GetA(); // 20

    int b = pCTest->GetB();    // 30

    int c = pCTest->GetC();    // 10


    return 0;
}


阅读(382) | 评论(0) | 转发(0) |
0

上一篇:atoi API

下一篇:检测CPU字节序

给主人留下些什么吧!~~