APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : SEMESTER 6

Year : 2018

Term : MARCH

Scheme : 2015 Full Time

Course Code : EC 312

Page:10





PDF Text (Beta):

// Print the area of the object. cout <<
"Total area: " << Rect.getArea() << endl;
return
9;
}

4a. A pointer to a C++ class is done exactly the same way as a pointer to a structure and to
access members of a pointer to a class you use the member access operator -> operator, just
as you do with pointers to structures. Also as with all pointers, you must initialize the pointer

before using it.

Let us try the following example to understand the concept of pointer to a class —

#include

using namespace std;

class Box {
public:
// Constructor definition
Box(double 1 = 2.6, double ७ = 2.0, double h = 2.69) [|

cout <<"Constructor called." << endl;

length = 1;
breadth = b;
height = h;

}
double Volume() {

return length * breadth * height;

private:

double length; // Length of a box

Similar Question Papers