Question
1.
#include
2.
using namespace std;
3.
class Car
4.
{
5.
public:
6.
int speed;
7.
};
8.
int main()
9.
{
10.
int Car :: *pSpeed = &Car :: speed;
11.
Car c1;
12.
c1.speed = 1;
13.
cout
What is the output of this program?
1.
#include
2.
using namespace std;
3.
class Car
4.
{
5.
public:
6.
int speed;
7.
};
8.
int main()
9.
{
10.
int Car :: *pSpeed = &Car :: speed;
11.
Car c1;
12.
c1.speed = 1;
13.
cout
Answer: Option C
Was this answer helpful ?
In this program, We are printing the value by direct access and another one by using pointer
to member.
Output:
$ g++ ptm2.cpp
$ a.out
1
2
Was this answer helpful ?
Submit Solution