코드를 컴파일 할 때 오류가 발생하는 이유는 무엇입니까? 현재 파일에서 추출해야하는 값을 출력하여 쓴 함수를 테스트하려고합니다.Visual Studio 2015 : "비표준 구문을 사용하여 '&'를 사용하여 멤버에 대한 포인터를 만듭니다."오류
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;
}
난 단지 내가 선언과 게임 보드 헤더 및 소스에 정의 된 기능을 시험하고 있습니다 파일이므로 다른 포함 된 파일은 앞으로 사용되지만 이미 테스트를 마쳤으며 throw되지 않습니다 컴파일하고 실행할 때 오류가 발생합니다.
감사합니다.
'inputFile.open; // 여기에 오류가 발생했습니다.'- 이것은'C++ '에서 함수를 호출하는 방식이 아닙니다. 괄호는 어디에 있습니까? 이상한 점은 여기에서 괄호를 생략했지만'is_open()'함수에 대해서는 괄호를 생략하지 않았다는 것입니다. – PaulMcKenzie
@paulMcKenzie, 고마워요! 나는 아직도 언어를 배우고있다! – Harrison