Question 1:
triangle(int b, int h) : _base(&b), _height(&h) { } // Line-1
// LINE-1: Complete Constructor definition
~triangle() {
_base = 0; // Line-2
_height = 0;// LINE-2: Complete destructor to delete both data pointers
}
double area();
};
double triangle::area() { // LINE-3: Complete function header
Question 2:
mutable int _sem; // LINE-1
public:
Student(int roll, string name, int sem)
: _roll(roll), _name(name), _sem(sem) { }
void promote() const { // LINE-2
_sem++;
}
void display() const{ // LINE-3
Question 3:
#include <iostream>
#include <string>
using namespace std;
class Complex {
const int _r, _i;
public:
Complex() : _r(0), _i(0){ } // LINE-1
Complex(int r) : _r(r),_i(0) { } // LINE-2
Complex(int r, int i) : _r(r), _i(i) { } //
Question 4 :
integer objA; // LINE-1: Invoke Default Constructor
integer objB(val); // LINE-2: Invoke Parameterized Constructor
integer objC = objB; // LINE-3: Invoke Copy Constructor
0 Comments:
Post a Comment