如何在VS2015中添加一些头文件

  • 本文关键字:文件 添加 VS2015 c++
  • 更新时间 :
  • 英文 :


我已经阅读了Visual Studio 2012添加新的头文件,但我的问题还没有解决!无论如何,我想在我的项目中添加foo.h

#pragma once
void MyLDA(vector<int>, Mat_<float>, Mat&, Mat&);

现在,foo.cpp

#include "stdafx.h"
#include "foo.h"
using namespace std;
auto getIndices = [](const std::vector<int>& vec, const int value)
{
//some code
}
void MyLDA(vector<int> gnd, Mat_<float> _data, Mat &eigvector, Mat &eigvalue)
{
//some code
}

当我构建我的项目时,我收到此错误:

'vector': undeclared identifier

type 'int' unexpected

'my_project': identifier not found

您需要#include <vector>才能使用std::vector。 此外,最佳做法是避免using namespace std;,而是编写std::vector。 有些人还建议对于OpenCV类,例如Mat。 (值得一提的是,我自己的编码风格是在 STL 类前面编写std::,因为有很多带有自定义stringarray类的遗留代码,但要编写coutmemcpy()而不是像std::cout这样的东西,用于在 STL 之前很久就存在的东西。

在分配 lambda 表达式后还有一个缺失的分号,乍一看,它恰好很像函数定义。 (@BarmakShemirani抓住了它,不是我。

最新更新