+ 13
How to do this in c++
I have two classes A and B A has a member function f that receive an object of B B also have a member function g that receive an object of A how can I do this I got error: B hasn't been declared the code https://code.sololearn.com/caq8A8QBbW9s/?ref=app
13 Respuestas
+ 12
you are legend ~ swim ~ thank you very much
+ 12
You are the best men I like you
+ 10
*** I didn't see your answer I am sorry you have preceded
+ 9
*** I tried it , id didn't work on codeblocks
+ 9
the same error I got here check the code now please
+ 9
yes exactly
+ 7
~ swim ~
Coder Kitten
check that I could do what I want without reference by defining the function of A after B
+ 2
Well it's giving error because the classes you define is both different classes and you are defining object of A class in method of class B and vice versa in class class A.
So either declare
class B:public A
Or
Class A: public B
So the methods you define can use object of it's parent class.
+ 1
You can write both A and B in separeted header file and include A in B and B in A
0
There is no output
- 1
.
- 1
هلل
- 3
Fyu