Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Suppose we further define a derived class as below: class Myclassroom: public Myclass{ int width,length; public: void set(int w,int l){width=w,length=l;} }; (1) add a

1. Suppose we further define a derived class as below:

class Myclassroom: public Myclass{

int width,length;

public:

void set(int w,int l){width=w,length=l;}

};

(1) add a constructor for Myclassroom; 1

(2) define an derived object obj2; 1

(3) change the value of obj2's width as 20 , the value of length as 30; 1

(4) change the member obj2's count of obj2 as 30 . 1

2.

#include

using namespace std;

class test{

int num;

double f;

public:

test();

int getint( ){return num;}

double getdouble( ){return f;}

(5) ;

};

test::test( ){

cout<<Initializing default<

num=3;

(6) ;

}

test::~test( ){

(7) ;

}

int main(){

(8)

cout< <

return 0;

}

3. Given a node definition segment:

class Node{

int data;

Node *next;

public:

Node(int d, Node *p=NULL){data=d; next=p;}

void setdata(int d){data=d;}

void setnext(Node *p){next=p;}

int getdata(){return data;}

(9) getnext() {return next;}

};

Please complete the definition of the class linked list:

class Linkedlist {

Node (10) ;

public:

Linkedlist(int d) {

Node* new_node = (11) ;

head = new_node;}

Linkedlist() { head = NULL; }

Node* end() {

Node *p = head;

if ( (12) ) // to tell whether it is an empty list

while (p->getnext() != NULL) { (13) ; }

return p;

}

};

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

discuss the different dimension of feasibility? expl@in

Answered: 1 week ago