samedi 1 août 2020

passing structure as a void *

ALL,

In Foo.h:

struct Properties
{
    std::string name;
    int size;
};

In Foo.cpp:

void *properties;
if( type == 0 )
{
    Properties prop;
    prop.name = "abc";
    prop.size = 5;
    properties = ∝
}
Properties p = *static_cast<Properties *>( properties );

For some reason p object is not valid.

I need to pass different parameters to a function and so wanted to use void *.

Or maybe this is easier in C++11?

TIA!!

Aucun commentaire:

Enregistrer un commentaire