Visual Studio 2015:获取"non standard syntax, use '&' to create a pointer to member"错误
Visual Studio 2015: Getting "non standard syntax, use '&' to create a pointer to member" error
当我尝试编译代码时,超级困惑。我目前正在尝试通过打印应该从文件中提取的值来测试我写的功能。
gameboard.cpp
#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <fstream>
#include "error.h"
using namespace std;
int boardDim(ifstream & inputFile, unsigned int x, unsigned int y) {
inputFile.open; //error is thrown here
if (!(inputFile.is_open())) {
throw fileNotOpen;
}
else {
stringstream output(inputFile.getline); //error is also thrown here
if (output >> x) {
if (output >> y) {
return success;
}
return secBoardVarErr;
}
return firstBoardVarErr;
}
cout << x << endl;
cout << y << endl;
}
gameboard.h
#ifndef GAMEBOARD_H
#define GAMEBOARD_H
#include <iostream>
using namespace std;
//takes in dimensions of board from file
int boardDim(ifstream &, unsigned int, unsigned int);
#endif !GAMEBOARD_H
主要功能
#include "stdafx.h"
#include "functions.h"
#include "gamepieces.h"
#include "gameboard.h"
#include "error.h"
int main(int argc, char * argv[])
{
ifstream x("test.txt");
int test = 0;
cout << boardDim(x, 0, 0) << endl;
return success;
}
我只是在游戏板标题和源文件中测试我声明和定义的功能,因此将来将使用另一个包含的文件,但已经进行了测试,并且在我编译并运行时不会丢弃错误。
谢谢!
inputFile.open
是一个函数,与 inputFile.getline
相同,因此您在这里拥有的是句法错误。正确的语法是:
inputFile.open()
和
inputFile.getline()
相关文章:
- "error: no matching function for call to"构造函数错误
- 调用专用模板时出错"no matching function for call to [...]"
- C++ Singleton - Prevent ::instance() to variable
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- Visual Studio Code "undefined reference to `WinMain@16'"
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 如何解决"invalid conversion from 'char' to 'const char*'"
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 为什么"non-standard syntax; use '&' to create a pointer to member"在 CTOR 中使用线程?
- 如果它被定义为 C++ 类中的成员函数,我得到了"non-standard syntax; use '&' to create a pointer to member"
- libgit2:git_clone() 失败并出现"failed to create ssl object"错误
- 使用c_str时"Use & to create a pointer to a member"
- Visual Studio 2015:获取"non standard syntax, use '&' to create a pointer to member"错误
- MFC 错误仅在发布模式下"Failed to create an empty document"
- IMAP:从C++程序发送电子邮件时"Unable to create selectable TCP socket"
- Visual Studio 2015 "non-standard syntax; use '&' to create pointer for member"
- 了解重载运算符。收到"non-standard syntax; use '&' to create a pointer to a member"错误
- Visual Studio 2015 "non-standard syntax; use '&' to create a pointer to member"
- GLFW 无法创建窗口:"GLX: Failed to create context: GLXBadFBConfig"
- Visual Studio 2015 中的"non-standard syntax; use '&' to create a pointer to member"错误