コードをコンパイルしようとすると、何がエラーを投げかけているのか混乱します。私は現在、ファイルから抽出する必要がある値を出力することで書き込んだ関数をテストしようとしています。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;
}
私は私が宣言された関数をテストし、ゲームボードヘッダとソースで定義されていしたがって、他のインクルードファイルは将来使用されますが、すでにテストされており、スローされていません私がコンパイルして実行するとエラーが発生します。
ありがとうございました!
'inputFile.open。 //ここにエラーがスローされます。 ' - これは' C++ 'で関数を呼び出す方法ではありません。かっこはどこにありますか?不思議なことに、ここではカッコを省略していますが、 'is_open()'関数の直後にそれを残すことはありませんでした。 – PaulMcKenzie
@paulMcKenzie、ありがとうございます!私はまだ言語を学んでいる! – Harrison