I have this code
class inner {
public:
double data;
string label;
};
class middle {
public:
inner set[5];
int cnt;
};
class outer {
public:
middle part1;
inner part2;
};
inner x;
middle y;
outer z;
And I need to know which of the following Statement is Valid and which one is Invalid
(a) x.label = “inside”; (b) z.part1 = y; (c) z.part2.inner = x; (d) x.data = y.cnt; (e) cout << x; (f) z.part1.set[2] = x; (g) outer.part1 = middle; (h) outer.part1.set[0].data = 1.0; (i) y.set.label = “from middle”; (j) cin >> z.part1.cnt;
---------- Post added at 04:11 PM ---------- Previous post was at 04:10 PM ----------
I answered them, but I am not sure about it :p
(a) x.label = “inside”; [B][COLOR=Red]Valid[/COLOR][/B] (b) z.part1 = y; [B][COLOR=Red]Valid[/COLOR][/B] (c) z.part2.inner = x; [B][COLOR=Red]Valid[/COLOR][/B] (d) x.data = y.cnt; [B][COLOR=Red]Valid[/COLOR][/B] (e) cout << x; [B][COLOR=Red]Invalid[/COLOR][/B] (f) z.part1.set[2] = x; [B][COLOR=Red]Invalid[/COLOR][/B] (g) outer.part1 = middle; [B][COLOR=Red]Invalid[/COLOR][/B] (h) outer.part1.set[0].data = 1.0; [B][COLOR=Red]Valid[/COLOR][/B] (i) y.set.label = “from middle”; [B][COLOR=Red]Valid[/COLOR][/B] (j) cin >> z.part1.cnt; [B][COLOR=Red]Valid[/COLOR][/B]
:P What do think


Sign In
Create Account

Back to top









