无法从头文件访问函数
Can't access function from header file
//head.h//
extern int sum(int,int);
//head.cpp//
#include "head.h"
#include "stdafx.h"
int sum(int x, int y)
{
return (x+y);
}
//mainfn.cpp//
#include "head.h"
#include "stdafx.h"
#include string
#include iostream
#include stdio.h
using std::string;
using std::cout;
using namespace System;
int main()
{
int x=10,y=2;
printf("value: %d",sum(x,y));
Console::ReadLine();
return 0;
}
在Visual studio 2005中构建时,这个vc++项目给出以下错误:
error C3861: 'sum': identifier not found.
有谁能帮我一下吗? 您需要在 stdafx.h之后放置head.h。当启用预编译头文件时,编译器将忽略在stdafx.h .
要么从项目中删除stdafx.h,然后转预编译头文件。或者尝试将head.h移动到 stdafx.h之后,而不是之前。
相关文章:
- 如何在函数外部访问函数中局部变量的值?
- UChildActorComponent的ChildActorClass中的访问函数
- 访问函数变体时"Invalid conversion"错误
- 在将向量作为参数传递给函数后,我无法访问函数中向量的元素
- 在64位DLL中访问函数的错误
- 访问函数中 const char *arr[] 的元素
- 访问函数的调用方类型
- 访问函数中的使用声明:与范围相关的问题
- 通过 -> 语法 c++ 从指针访问函数
- 在函数中使用 const 引用参数访问函数中成员的最佳实践 C++.
- 从另一个文件(C++,QT)访问函数未解析的外部
- 如何从主(C )访问函数中的值
- 访问函数 c++ 中的全局变量
- C++ GoogleTest 使用夹具 - 无法访问函数指针定义
- 在不知道名称的情况下访问函数参数
- C++:直接访问器或类内的访问函数
- 无法从对象访问函数
- 类的2D矢量在访问函数时出错
- 为什么在C++中访问函数时没有对象
- 我无法使用指针数组从main访问函数(在类中)