Illustrate Construction of Object
Learn to illustrate the construction of an object.
We'll cover the following...
Problem
Does the constructor actually “construct” an object? Can this be proven?
Coding solution
Here is a solution to the problem above.
Press + to interact
// Program to illustrate construction of object#include <iostream>class Sample{public :Sample( ){std :: cout << "Address of object passed to this function = "<< this << std :: endl ;}} ;int main( ){Sample s ;std :: cout << "Address of object s = " << &s << std :: endl ;return 0 ;}
Explanation
The constructor doesn’t allocate space for an object. ...