I'm pretty new to C++ and I am just experimenting it so I was looking through an exercise book on C++ and I found an interesting problem where you have to use classes. I figured out a solution to it but my solution is writen like I would write it in Javascript. So I started writing it in C++ but I don't know if is it possible and if yes , how to create a member of a class as an object of another class dynamically inside a member function of the same class.In Javascript , I could do this with constructors :
function AConstructor() {
this.method = function() {
this.property = new OtherConstructor()
}
}
Is this possible in C++?