by Rawan Babar Khan on
My today's paper :
Objectives were easy and straight-forward.
Objectives were easy and straight-forward.
Q1 Consider the following code segment:
Crs1-Crs2-Crs3;
Where - operator is overloaded, and Crs1, Crs2, Crs3 are objects of “Course” class. When compiling the above statement, the compiler automatically covert the above statement in an appropriate function calls.
Q2 Write any two advantage(s) of declaring a member function as const?
Q3 Consider the following code segment:
class Course{
private:
char * bufferPtr;
int size;
public:
Course();
Course(char * ptr);
void SetCourse(char c, int pos);
};
Implement the SetCourse method, such that it changes a single character at nth location of string pointed by bufferPtr pointer.
Q4 Consider the class given below what will be the values in variables x,y and z after creating object of this class,
class ABC{
int x;
int y;
int z;
public:
ABC();
};
ABC::ABC():x(10),z(y),y(x)
{
…
}
Q 5 Consider the following code segment:
class String
{
int size;
char * bufferPtr;
public:
char & operator[](int);
};
Write C++ code to overload subscript [] operator for String class.
Comments
Post a Comment
Please give us your feedback & help us to improve this site.