This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

compile error when initializing descendant struct


Dear list,
  When I attempt to compile the following code (test2.cpp):


struct A {
  int x;
};

struct B : public A {
  int y;
};

const B b = {1, 2};


g++ gives the following error:

test2.cpp:9: error: scalar object 'b' requires one element in initializer

My goal is to incorporate a large set of structs in a DSO (so that
they reside in the read only section). I don't see why this code
should not compile.

Thanks,
-Dave


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]