Why is the header file included in itself and not the .cpp file within the constructors section of the classes and objects lesson for C++?

I was working through the C++ course and I’ve reached the section that mentions constructors. However, the code below gave me pause.

// city.hpp
#include "city.hpp"
class City {
  std::string name;
  int population;
  City(std::string new_name, int new_pop);
// city.cpp
City::City(std::string new_name, int new_pop)
  // members get initialized to values passed in 
  : name(new_name), population(new_pop) {}

The top of the code has #include “city.hpp” within the header file. Shouldn’t this be moved down into the city.cpp file section?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.