Question: THIS IS MY CODE FOR THIS PLEASE ADJUST AND FIX IT. IN C++ ------------------CITY.H (FILE) ------------------ #ifndef CITY_H #define CITY_H #include #include using namespace std;

 THIS IS MY CODE FOR THIS PLEASE ADJUST AND FIX IT.IN C++ ------------------CITY.H (FILE)------------------ #ifndef CITY_H #define CITY_H #include #include using namespace

THIS IS MY CODE FOR THIS PLEASE ADJUST AND FIX IT.

IN C++

------------------CITY.H (FILE)------------------

#ifndef CITY_H

#define CITY_H

#include

#include

using namespace std;

//City class defnition

class City

{

public:

//setter metod for name

void setName(string name)

{

this->name=name;

}

//setter metod for population

void setPopulation(int population)

{

this->population=population;

}

//getter metod for name

string getName() const

{

return this->name;

}

//getter metod for population

unsigned int getPopulation() const

{

return this->population;

}

//printInfo() method to print data members

void printInfo() const

{

cout

cout

}

//making data members protected so that subclasses can access

protected:

//data members declaration

string name;

unsigned int population;

};

#endif

------------------COASTALCITY.H(FILE)------------------

#ifndef COASTALCITY_H

#define COASTALCITY_H

#include "city.h"

#include

#include

using namespace std;

//CoastalCity class class defnition //CoatalCity class inherits City class CoastalCity:public City

{

private:

//data members declaration

string waterName;

unsigned int beachNum;

public:

//default constructor defnition

CoastalCity()

{

//assigning default values

name="N/A";

population=0;

waterName="N/A";

beachNum=0;

}

//setter metod for waterName

void setWaterName(string waterName)

{

this->waterName=waterName;

}

//setter metod for beachNum

void setBeachNum(int beachNum)

{

this->beachNum=beachNum;

}

//getter metod for waterName

string getWaterName() const

{

return this->waterName;

}

//getter metod for beachNum

unsigned int getBeachNum() const

{

return this->beachNum;

}

//printInfo() method to print data members

void printInfo() const

{

//calling printInfo() methode of the base class City::printInfo();

cout

cout

}

};

#endif

------------------MAIN.CPP(FILE)------------------

#include

#include "city.h"

#include "coastalcity.h"

using namespace std;

int main()

{

//creating CoastalCity object

CoastalCity cc;

//calling printInfo() method

cc.printInfo();

//setting name

cc.setName("San Fransisco");

//setting population

cc.setPopulation(900000);

//setting water name

cc.setWaterName("SF Bay");

//setting number of beaches

cc.setBeachNum(10);

//calling printInfo() method

cc.printInfo();

return 0;

}

1 Class CoastalCity First, create a header file city.h that defines class City as follows. #ifndef CITY_H #define CITY_H #include class City public: void setName (string name) {this -> name name; } void set Population (unsigned int population) { this -> population = population; 3 string getName() const {return this-> name; } unsigned int get Population () const {return this -> population; } void printInfo() const { cout

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 Databases Questions!