AND SOLUTIONS RATED A+
✔✔given the c++ class definition:
class employee {char *name; long id; char *department;}
class manager1 {employee empl; short rank;}
class manager2: public employee {short rank;}
what class is defined using a containment relationship - ✔✔manager1
✔✔given the c++ class definition:
class employee {char *name; long id; char *department;}
class manager1 {employee empl; short rank;}
class manager2: public employee {short rank;}
how does an object m of manager1 class access the member id - ✔✔m.empl.id
✔✔given the c++ class definition:
class employee {char *name; long id; char *department;}
class manager1 {employee empl; short rank;}
class manager2: public employee {short rank;}
how does an object n of manager2 class access member id - ✔✔n.id
✔✔what type casting mechanism should be used if you want to cast an integer value to
a double value - ✔✔static_cast
✔✔what type casting mechanism should be used if you want to change pointer type for
pointing to a different object in an inheritance hierarchy - ✔✔dynamic_cast
✔✔what features are supported in c++ - ✔✔virtual function, function overloading,
operator overloading
✔✔what type of values can a throw-statement throw (return) - ✔✔primitive type, string
type, object types
✔✔what is a generic type - ✔✔the type can be determined at run time
✔✔can a multithreading program take longer time than a single thread program that
solves the same problem - ✔✔yes
✔✔why do we need the spin synchronization at the end of a MapReduce process -
✔✔to make sure that all the threads complete their tasks
, ✔✔map and reduce is a concept for - ✔✔defining parallel computing process
✔✔given the c++ code:
class Queue {
private: int queue_size;
protected: int *buffer, front, rear;
public: Queue(int n){
front=0; rear=0; queue_size=n;
buffer=new int[queue_size];}
virtual ~Queue(void) {delete buffer; buffer=NULL;}
void enqueue(int v) {
if (rear<queue_size) buffer[rear++]=v;}
int dequeue(void){ // return and remove first element
if(front < rear) return buffer[front++];}}
Queue IntitialQueue(100);
void main() {
Queue *myQueue = new Queue(50);
myQueue->enqueue(23);
InitialQueue->enqueue(25);
delete myQueue;}
what is the destructor - ✔✔~Queue(void)
✔✔given the c++ code:
class Queue {
private: int queue_size;
protected: int *buffer, front, rear;
public: Queue(int n){
front=0; rear=0; queue_size=n;
buffer=new int[queue_size];}
virtual ~Queue(void) {delete buffer; buffer=NULL;}
void enqueue(int v) {
if (rear<queue_size) buffer[rear++]=v;}
int dequeue(void){ // return and remove first element
if(front < rear) return buffer[front++];}}
Queue IntitialQueue(100);
void main() {
Queue *myQueue = new Queue(50);
myQueue->enqueue(23);
InitialQueue->enqueue(25);
delete myQueue;}
what variable must be destructed by the destructor in queue class - ✔✔*buffer
✔✔given the c++ code:
class Queue {