/** =====================================================================================** Filename: class.cpp** Description:** Version: 1.0* Created: 09/02/2017 03:44:36 PM* Last Modified: 2019年09月03日 00:17:20* Revision: none* Compiler: gcc** Author: zt (),* Organization:** =====================================================================================*/#include <stdio.h>#include <stdlib.h>#include <iostream>using namespace std;#pragma pack(push)#pragma pack(1)class A{public:void a(){cout << "a" << endl;}protected:void b(){cout << "b" << endl;}public:uint8_t m_a;uint8_t m_b;uint8_t m_c;uint32_t m_d;};class B : public A{public:void ba(){b();}};class C{public:C(){a = 1;b = 2;c = 3;}void Print(){//int* p = reinterpret_cast<int*> ( this );//printf ( "%d sizeof(C)=%d\n", *p, ( int ) sizeof ( *this ) );printf ( "this=%p\n", this );}int a;char b;short c;};#pragma pack(pop)int main ( int argc, char* argv[] ){( void ) argc;( void ) argv;//A a;//a.a();//B b;//b.ba();//fprintf ( stderr, "sizeof A=%d\n", ( int ) sizeof ( a ) );//uint8_t* p = reinterpret_cast<uint8_t*> ( &a );//memset ( p, 0x55, sizeof ( a ) );//fprintf ( stderr, "%02x %02x %02x %04x\n", a.m_a, a.m_b, a.m_c, a.m_d );C c;c.Print();printf ( "instance = %p\n", &c );return 0;}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。