'c++ equivalent to python self.attribute = ObjectInstance()

i want to know if there is an equivalent way of doing this in c++:

class B:
    def foo(self,parameter):
        print("B method call from A, with non static method",parameter)

class A:
    def __init__(self):
        self.b = B()

parameter = 10
a = A()
a.b.foo(parameter)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source