2017-02-23 1 views
0

코드를 컴파일 할 때 오류가 발생하는 이유는 무엇입니까? 현재 파일에서 추출해야하는 값을 출력하여 쓴 함수를 테스트하려고합니다.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되지 않습니다 컴파일하고 실행할 때 오류가 발생합니다.

감사합니다.

+0

'inputFile.open; // 여기에 오류가 발생했습니다.'- 이것은'C++ '에서 함수를 호출하는 방식이 아닙니다. 괄호는 어디에 있습니까? 이상한 점은 여기에서 괄호를 생략했지만'is_open()'함수에 대해서는 괄호를 생략하지 않았다는 것입니다. – PaulMcKenzie

+0

@paulMcKenzie, 고마워요! 나는 아직도 언어를 배우고있다! – Harrison

답변

0

inputFile.openinputFile.getline과 같은 기능이므로 구문 오류가 있습니다. 정확한 구문은 다음

inputFile.open() 

inputFile.getline() 
+0

고맙습니다. 나는 이것이 내가 찾고 있었던이 실수라고 믿을 수 없다. 약 한 시간 동안. – Harrison

+0

@ 하리슨이 게시물이 질문에 대한 답변을 경우 표시하도록하십시오. – arrowd

+0

문제 없습니다. 도움이되는 답변을 upvote하십시오. ;) C++ 모험에서 행운을 빈다; 컴파일러 오류는 종종 비밀스럽고 오해의 소지가 있습니다. 따라서 그러한 것들을주의해야합니다. –

관련 문제