Let's suppose we have this header file:
People.h
pch.hCode:class People { public: People(const std::string &name, int age) : m_name(name), m_age(age) { } inline const std::string& GetName() const { return m_name; } inline int GetAge() const { return m_age; } inline std::string ToString() const { std::stringstream ss; ss << m_name << " , " << m_age; return ss.str(); } private: std::string m_name; int m_age; };
If you include a header file like that in a precompiled header, will it work!Code:#include "People.h"
If you include that pch.h in a bunch of .cpp files, you basically include People.h too. So if I make changes to that .cpp files, wouldn't People.h be recompiled each time too?
Also what happens if I have something like this:
MyClass.h
MyClass.cppCode:#include "People.h" class MyClass { public: MyClass(); //Allocate on the stack. People people("name", 20); }
Will the above recompile People.h every time I make changes?Code:#include "pch.h" #include "MyClass.h" //implementation of MyClass





Reply With Quote
