c++ - default value at declaration time -
Is there any way to declare an object's value (I Is there a library in it? C + +11, you can provide default initiator within the definition of a class: In the past, you have to use Constructor Starter: Usage: Perhaps you find the solution for @missletters useful: You can add int /
class MyClass {MyInt & lt; 1 & gt; My_int; };
struct foo {int a = 11; Fu () = default; // still a trivial class :-)};
struct bar {int b; Bar (): B (11) {} / Non-trivial constructor :-(};
Fu x; (Xa == 11 & amp; yb == 11);
template & Lt; typename t, t inteveal & gt; straight initial type {typedef T type; static type const initial_value = initVal; // ban type and operator (return); {return x;} type const and operator () const {return X;} initial type (): x (intall) {} private: type x;};
InitializedType & lt; int, 11> n; to get something, it looks like a
int , but value
11 Starts with.
Comments
Post a Comment