Question: C++ learning about classes, this includes Lab01.cpp , Box.h , Box.cpp //Box.h: // Box class definition class box { public: box();// Constructor - null box(int,int);//

C++ learning about classes, this includes Lab01.cpp , Box.h , Box.cpp

//Box.h:

// Box class definition

class box

{ public:

box();// Constructor - null

box(int,int);// Constructor - parameters

~box();// Destructor

bool get(istream &in);// Input dimensions

void put(ostream &out);// Output dimensions

intarea();// Calculate area

intperimeter();// Calculate perimeter

private:

int height,width;// Dimensions

};

_____________________________________________________________________________

//Box.cpp:

#include

using namespace std;

#include "Box.h"

/**************************************

* Constructor - no parameters

**************************************/

box::box()

{ cout << "Box " << this << " created ";

height = 0;

width = 0;

}

/**************************************

* Constructor - all parameters

**************************************/

box::box(int h,int w)

{ cout << "Box " << this << " created ";

height = h;

width = w;

}

/**************************************

* Destructor - optional

**************************************/

box::~box()

{ cout << "Box " << this << " destroyed ";

}

/**************************************

* Get

**************************************/

bool box::get(istream &in)

{ in >> height;

in >> width;

return in.good();

}

_________________________________________________________________________________

//Lab01.cpp:

// with step three uncommented

#include

using namespace std;

#include "Box.h"

/***********************************

* Main()

***********************************/

void main()

{ class box a,b,c;

// Step 3

// Display empty boxes

cout << "a = ";

a.put(cout);

cout << endl;

cout << "b = ";

b.put(cout);

cout << endl;

cout << "c = ";

c.put(cout);

cout << endl;

/**/

/** Step 6

// New boxes

a = box(3,5);

b = box(4,6);

**/

/** Step 7

// Display boxes

cout << "a = ";

a.put(cout);

cout << endl;

cout << "b = ";

b.put(cout);

cout << endl;

**/

}

1..You should get a link error - the put() function is missing.

Severity

Code

Description

Error

LNK2019

unresolved external symbol "public: void __thiscall box::put(class std::basic_ostream > &)" (?put@box@@QAEXAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z) referenced in function _main

Add a put() function to Box.cpp that will output the dimensions of the box in the form height x width.

Examples: "3x5" or "4x6"

Lastly, Compile the program and run project again. Uncomment the section for step 6.What do you think the two extra pair of constructor/destructor messages represent?Uncomment the section for step 7 so you can output the new values of the boxes.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!