0

How to call member function of different class?

https://code.sololearn.com/cyLklw7Tto3B/?ref=app I want to call fun() function only from class A and object is created of class A. Please help

1st May 2021, 9:28 PM
anas hassan
anas hassan - avatar
1 Odpowiedź
+ 2
The method fun() is not a static method, you need to call it from an object of class B. To be able to instantiate B, you need a complete definition of the class. However, for a complete definition, you also need a complete definition of A because of the inheritance. Therefore, you need to delay the definition of A::call() until B is known, resulting in the following structure: https://code.sololearn.com/ckdbf3Qdter1/?ref=app
1st May 2021, 9:43 PM
Shadow
Shadow - avatar