union inside struct

// union inside struct.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
struct TestStruct
{  
public:
    int a;
    int b;

    union ZZZ // Note here!!
    {
public:
        int d;
    };
};

int _tmain(int argc, _TCHAR* argv[])
{
TestStruct instance;
instance.a = 100;
instance.b = 200;
instance.ZZZ::d = 300;
//instance.ZZZ::c = {'G','c','A'};
/*TestStruct::ZZZ uni;
uni.d =  300;*/

printf("%d\n", instance.a);
printf("%d\n", instance.b);
return 0;
}

Comments

Popular posts from this blog

Smart Pointers in C++ and How to Use Them

Operator Overloading in C++

How would you read in a string of unknown length without risking buffer overflow