Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
struct A
4.
{
5.
int i;
6.
char j;
7.
float f;
8.
void func();
9.
};
10.
void A :: func() {}
11.
struct B
12.
{
13.
public:
14.
int i;
15.
char j;
16.
float f;
17.
void func();
18.
};
19.
void B :: func() {}
20.
int main()
21.
{
22.
A a; B b;
23.
a.i = b.i = 1;
24.
a.j = b.j = 'c';
25.
a.f = b.f = 3.14159;
26.
a.func();
27.
b.func();
28.
cout
Options:
A .  Allocated
B .  Error
C .  3.14159
D .  None of the mentioned
Answer: Option A

In this program, We used access specifiers for structures, As we declared all methods as public, 

The values can be allocated.
Output:
$ g++ acc.cpp
$ a.out
Allocated



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers