yawnobleix yawnobleix - 8 months ago 64
C++ Question

Confusion about structs

It's been a while since I have done C++ so bear with me. I have the following struct:

struct sPage { U16 _; };
typedef sPage tPage;

But when I try to do:

tPage pagenumber = 0;

I get the following error: "No suitable constructor exists to convert from int to sPage". What am I doing wrong?


You need curly braces to initialize:

tPage pagenumber = {0};

or make your own constructor:

struct  sPage
    U16 _;

    sPage(U16 val) : _(val) { }