+ 6

Please someone explain cout<<c1.a.b+c2.b.a;

5th Jul 2017, 6:30 PM
Amit Raghuwanshi
Amit Raghuwanshi - avatar
10 Respuestas
+ 6
Divide it like this (c1.a).b it means c1.a is referring to structure of type A then dot b means I am accessing the member float b of structure A same way c2.b.a means I am referring to structure of type B and then by dot a I am accessing member a of structure B..answer should be this c1.a.b = 2.0 and c2.b.a= 8.0 =10 (sum) I think 10 should be answer
5th Jul 2017, 7:00 PM
Joy Das
Joy Das - avatar
+ 5
Code ?? any ?? I mean if you could post the code then it would be easier to explain
5th Jul 2017, 6:44 PM
Joy Das
Joy Das - avatar
+ 5
struct A { int a; float b;} struct B{int b; float a; } struct C { A a;B b; } int main(){ C c1={1,2,3,4}; C c2={5,6,7,8}; cout<<c1.a.b+c2.b.a; }
5th Jul 2017, 6:49 PM
Amit Raghuwanshi
Amit Raghuwanshi - avatar
+ 4
Is it correct ?? @amit
5th Jul 2017, 7:02 PM
Joy Das
Joy Das - avatar
+ 4
1 thing add semicolon after each structure declaration 😃
5th Jul 2017, 7:06 PM
Joy Das
Joy Das - avatar
+ 3
i DONT UNDERSTAND this problem either; why the objects chosen ones are 2 and 8???
8th Apr 2018, 12:47 PM
Gustave A C/D C ☢️ 🛸🛸🛸
Gustave A C/D C ☢️ 🛸🛸🛸 - avatar
+ 2
thank you @joy
5th Jul 2017, 7:02 PM
Amit Raghuwanshi
Amit Raghuwanshi - avatar
+ 2
yes answer is 10 @joy.... and I have one more question is it like?? c1 ={1,2,3,4}= {aa,ab,bb,ba}
5th Jul 2017, 7:07 PM
Amit Raghuwanshi
Amit Raghuwanshi - avatar
+ 1
how c1.a.b got 2 and c2.b.a got 8??
12th Oct 2017, 8:07 PM
Prasad K G
Prasad K G - avatar
+ 1
Thank you!😃
14th Oct 2017, 3:48 AM
Andy