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 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
