Question
1.
#include
2.
using namespace std;
3.
class Cat
4.
{
5.
public:
6.
int age;
7.
int weight;
8.
};
9.
int main()
10.
{
11.
Cat f;
12.
f.age = 56;
13.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class Cat
4.
{
5.
public:
6.
int age;
7.
int weight;
8.
};
9.
int main()
10.
{
11.
Cat f;
12.
f.age = 56;
13.
cout
Answer: Option B
Was this answer helpful ?
In this program, We passed the value from main function to class and returning it to the main
and then printing it.
Output:
$ g++ acc2.cpp
$ a.out
Gates is 56 years old
Was this answer helpful ?
Submit Solution