Explicit Invocation Constructors and destructors can be invoked (called) explicitly from the main() function. A constructor can be invoked as shown below: ClassName(params-list ); For example, constructor of Student class can be called as shown below: Student( ); In case of a destructor, we need to write the class name along with the destructor name as follows: object_name.ClassName::~ClassName( ); or object_name.~ClassName( ); For example, destructor of Student class can be called as follows: s1.~Student( ); A destructor can be called from a constructor as follows: 1 2 3 4
The post What is the explicit Invocation in Constructors appeared first on Coding Security.
What is the explicit Invocation in Constructors
read more
Tidak ada komentar:
Posting Komentar