我正在编写一个计划,旨在为一个班级 - 国家 - 以及面积最大的国家以及人口最密集的国家提供用户输入。然而,我有执行文件。如何在实现文件中使用构造函数?
什么应该进入我的默认构造函数?其他构造函数呢?这是我到目前为止有:
#ifndef COUNTRY_H
#define COUNTRY_H
#include <string>
class Country
{
public:
Country(string name, double area, int population);
Country();
string get_name() const;
double get_area()const;
int get_population()const;
double population_density(Country popDensity) const;
void largest_area(double a);
void largest_population(int p);
void most_dense(double d);
private:
string name;
double area;
int population;
};
#endif
和:
#include <iostream>
#include <string>
using namespace std;
#include "COUNTRY_H"
Country :: Country(string name, double area, int population)
{
}
Country :: Country();
{
}