Initializing member data with a member function

I have today learned the very useful new feature of C++ 11 which allows direct initialization of data members in the class declaration: class file_name { public: file_name(const char *input_file_name); ~file_name(); private: char *file_name=nullptr;

Constructors with access to private data

Still new to C++ and I'm trying to understand accessing private data, using constructors. How would I display the values of the data members of myClass? Any help would be great. Thanks class NumberClass { public: void func(); // assigns numeric const

Initializing the Data Member of Table 2D

I have a program like this: class A { int a[2][3]; public: A(int b[2][3]): a(b) {}; }; int main() { int b[2][3]; A myclass(b); return 1; } The compiler says: 1.cpp: In constructor 'A::A(int (*)[3])': 1.cpp:5:22: error: incompatible types in assignmen

Table of pointers to data members

class A { float m_Period; // a1 float m_Scale; // a2 }; I can have pointer to a data member like this: float A::*pFloat; For reason of handle members in cycle i need an array of such pointers. How to do this.Either std::vector<float A::*> pFloats; o

Pointer to members of Bruce Eckel's Thinking in C ++

The following is a paragraph from Bruce Eckel's Thinking in C++ (volume 1, 2nd edition, chapter 11) under the heading "Pointers to members": -a pointer needs an address, but there is no "address" inside the class; selecting the member

Define the data members in the constructor

I have got this little snippet of code, I want to be able to define each array element as a new data member. class Core_User { protected $data_members = array( 'id' => '%d', 'email' => '"%s"', 'password' => '"%s"', 'title' =&g

OCaml data members without initialization

I would like to create an object with a data member using OCaml but do not necessarily want to specify an initial value for the data member. Many examples seem to use a list but I would like to use a single instance of an object type I've created. Is