C++ initializing constants and inheritance -


I want to start stability in the child class, instead of the base class. And use it to get rid of the dynamic memory allocation (I know that there is already size size, and there will be some child classes with different constants). So I try:

  class A {public: const int x; A (): X (0) {} A (int x): x (x) {} zero F () {double y [is-> x]; }}; Class B: A {B (A): A (2) {}}; Very simple, but the compiler says:  

Error C2057: Expected Stable Expression

How can I say the compiler, is it really a constant?

This is not a stable though. It can still be modified by the constructor. There is a continuous allowance of only one array size compile time . When the compiler says "continuous expression", then it does not mean the expression, which gives a constant value, but a constant, such as "52" or "45" or something along those lines

Use instead.

Edit: "I know that there is already size shape, and there will be child-squares with a different constellation"

The only way to do this is to use a template To do.

  template & lt; Size_t x & gt; Class A {Public: Zero F () {Double Y [x]; }}; Type Apeed A & lt; 2 & gt; B;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -