2017-01-22 5 views
1

ここにエラーが何であるかわかりません。これは私がこれまでに使ってきた標準的なファイルオープンです。正しいものが含まれています。それはちょうど普通のifstreamです。これには何が問題なのですか?Error: "file"の前にイニシャライザが必要です(ifstreamを含む)。

#include <iostream> 
#include <fstream> 
#include <sstream> 

using namespace std; 

int main(){ 

struct item{ 
    string item; 
    string type; 
    int price; 
    } 

ifstream board; 
board.open("messageBoard.txt"); 

} 
+0

は確か? – Raindrop7

+0

'int price; } 'セミコロンがありません –

+0

ANSWER:構造体の最後にもセミコロンが必要です。おっとっと。 – grilam14

答えて

1

wow!誰もそれを気付くことはできません??あなたはコンパイル時エラーにredefinition

を取得するので、あなたは別の識別子としてクラス名を使用している

int main(){ 

struct item{  // 
    string item; // error C2580: redefinition of class name 'item' 
    string type; 
    int price; 
    } // missing a semicolon here `;` 

ので、あなたはそれらが異なることができます:それはコンパイル

struct Item // 
{ 
    string item; // now it's ok Item is not item 
    string type; 
    int price; 
}; 
関連する問題