我有一个预编译的头文件 stdafx.h 用于我项目中的所有源文件。因此,stdafx.h 中的所有头文件在项目的所有代码文件中都可用。
我不确定是否要重新包含已经在预编译头文件中的内容。你们有什么感想?
例如
标准数据文件
#pragma once
#include <memory>
my_class.h
#pragma once
#include <memory> // Re-include or not that's the question. Best practice?
struct my_class
{
};
typedef std::shared_ptr<my_class> my_class_ptr;
主文件
#include "stdafx.h"
#include "my_class.h"
int main()
{
}