Page 275 - C++
P. 275
2. (a) Differentiate between protected and private members of a class in
context of Object Oriented Programming. Also give a suitable
example illustrating accessibility/non-accessibility of each using a
class and an object in C++. 2
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included.
class TEST
{
long TCode;
char TTitle[20];
float Score;
public:
TEST() //Member Function 1
{
TCode=100;strcpy(TTitle,"FIRST Test");Score=0;
}
TEST(TEST &T) //Member Function 2
{
TCode=E.TCode+1;
strcpy(TTitle,T.TTitle);
Score=T.Score;
}
};
void main()
{
_______________ //Statement 1
_______________ //Statement 2
}
(i) Which Object Oriented Programming feature is illustrated by
the Member Function 1 and the Member Function 2 together
in the class TEST ? 1
(ii) Write Statement 1 and Statement 2 to execute Member
Function 1 and Member Function 2 respectively. 1
91 5 P.T.O.