+ 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

7th Oct 2019, 12:02 PM
ABADA S
ABADA S - avatar
13 Respuestas
+ 12
you are legend ~ swim ~ thank you very much
7th Oct 2019, 2:43 PM
ABADA S
ABADA S - avatar
+ 12
You are the best men I like you
7th Oct 2019, 3:14 PM
ABADA S
ABADA S - avatar
+ 10
*** I didn't see your answer I am sorry you have preceded
7th Oct 2019, 2:47 PM
ABADA S
ABADA S - avatar
+ 9
*** I tried it , id didn't work on codeblocks
7th Oct 2019, 2:21 PM
ABADA S
ABADA S - avatar
+ 9
the same error I got here check the code now please
7th Oct 2019, 2:35 PM
ABADA S
ABADA S - avatar
+ 9
yes exactly
10th Feb 2020, 3:49 PM
ABADA S
ABADA S - avatar
+ 7
~ swim ~ Coder Kitten check that I could do what I want without reference by defining the function of A after B
10th Feb 2020, 1:55 PM
ABADA S
ABADA S - avatar
+ 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.
7th Oct 2019, 12:53 PM
Chirag Kumar
Chirag Kumar - avatar
+ 1
You can write both A and B in separeted header file and include A in B and B in A
22nd Mar 2020, 12:03 AM
Waseem Alhalabi
Waseem Alhalabi - avatar
0
There is no output
2nd Jun 2020, 6:10 PM
David Adeboye
David Adeboye - avatar
- 1
.
9th Oct 2019, 7:05 AM
Abderrahmene Adjissi
Abderrahmene Adjissi - avatar
- 1
هلل
9th Oct 2019, 10:39 AM
بسـّـ✮ﮩ๋͜‏ـو𖤍᭄
- 3
Fyu
7th Oct 2019, 11:21 PM
Bereket Gume
Bereket Gume - avatar