What's the secret to static class members
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 29 08:24:52 PDT 2016
On Wednesday, 29 June 2016 at 15:18:53 UTC, Guido wrote:
> I'm using a static class member in a parent class, but can't
> get the compiler to see it.
>
> Class Grid{
> public:
> uint xdim;
> }
That's not static.... do `static uint xdim;` if you want it
static (in this context, static means it is shared across all
objects of the class)
> grid = new Grid;
> grid.xdim = 0;
>
> holder = new Holder;
> holder.xdim = 0;
those DO work if you declare the variable
auto grid = new Grid;
grid.xdim = 0;
auto holder = new Holder;
holder.xdim = 0;
More information about the Digitalmars-d-learn
mailing list