问题描述
我有一个内联类(仅限头文件),我有来自VS的stdafx.h
Hi,
I have an inline class (header file only), and I have the stdafx.h from VS
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
#include "TemplateContainer.h"
#include <vector>
然后我上课了....
Then I have my class....
#pragma once
#include "stdafx.h"
template < class T >
class TemplateContainer
{
private:
std::vector<T> myItems;
public:
TemplateContainer()
{
}
~TemplateContainer()
{
}
void add(T &item)
{
myItems.push_back(item);
}
};
这不会编译。我想如果我在stdafx中包含vector,那么当我的类包含stdafx时它会间接地引入vector.h。但是我必须明确地
This doesnt compile. I thought if I included vector in the stdafx then when my class includes stdafx it would indirectly pull in vector.h. However I have to explicitly
#include <vector>
获取我的要编译的类。我还应该做些什么来使用这个VS功能吗?
我尝试了什么:
我试过明确地包含文件并且它可以工作,但atdafx文档状态我只需要将它包含在stdafx.h文件中。
to get my class to compile. Is there anything else I should be doing to use this VS feature ?
What I have tried:
I have tried including the file explicitly and it works, but the atdafx docs state i only need to include it in the stdafx.h file.
推荐答案
这篇关于在VS 2015中使用stdafx.h - 必须手动包含头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!