我正在編寫一個計劃,旨在爲一個班級 - 國家 - 以及面積最大的國家以及人口最密集的國家提供用戶輸入。然而,我有執行文件。如何在實現文件中使用構造函數?
什麼應該進入我的默認構造函數?其他構造函數呢?這是我到目前爲止有:
#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();
{
}