Sail E0 Webinar
Question


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
Options:
A .  1
B .  2
C .  Both a & b
D .  None of the mentioned
Answer: Option C

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

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

Latest Videos

Latest Test Papers