The C ++ primer book has a section on class declarations and definitions. I do not understand everything in this sentence:
data members can only be specified as a class type if the class is defined.
I do not understand the logic of this proposal. How to specify a data member for a class type, what does this action mean?
This means that declaring a class member of a non-static class as class type T Trequires complete .
T
( , T .)
.
class foo; // forward declaration class bar { foo f; // error; foo is incomplete };
,
class foo {}; // definition class bar { foo f; // fine; foo is complete };
, , :
class A { public: A() {/* empty */} }; class B { public: B() {/* empty */} private: A myClassMember; // ok };
.... :
class A; // forward declaration only! class B { public: B() {/* empty */} private: A myClassMember; // error, class A has only been declared, not defined! };
, member , A , :
member
A
class A; class B { A member; };
, , , sizeof(A) .
sizeof(A)
, , , A :
class A { int value; }; class B { A member; };
, A ( ), member , :
class B { A* member; };
Source: https://habr.com/ru/post/1668897/More articles:How to start a qt project using a fake card in qtcreator? - vimConvert IA32 assembly to C - c codeDetecting multiple checked checkboxes - htmlHow to calculate the previous n days means using pandas? - pythonHow do you feel about futures in Akka Flow? - scalaUsing Parsing Soap Service Retrofit I came across such an exception (ie) an inappropriate body model in the class envelope model in the answer - javaAndroid Studio using the Tracer method to determine startup time at startup - androidJobDispatcher-Firebase job downloads are lost when the device is rebooted - androidData structure / design for product and delivery information - javaUnable to draw vertices with Z axis on screen - androidAll Articles