[問題] C++編譯error
大家好,小弟第一次寫C++,也是第一次使用C++ 2010 express,
目前只想讀入一個文字檔,但編譯遇到錯誤。
class Board {
int dim;
int ** cells;
public:
Board (int);
~Board();
string toString();
void set_square_value(int,int,int);
int Board::get_square_value(int,int);
static Board * fromFile(string); //fromFile是檔案讀取函式
bool checkForVictory();
int get_dim() {return dim;}
};
我宣告
133 Board * b = Board.fromFile("4x4_exam.txt");
編譯錯誤是
1>..\..\..\..\NU\sudoku.cpp(133): warning C4832: token '.' is illegal after
UDT 'Board'
1> ..\..\..\..\NU\sudoku.cpp(12) : see declaration of 'Board'
1>..\..\..\..\NU\sudoku.cpp(133): error C2275: 'Board' : illegal use of this
type as an expression
1> ..\..\..\..\NU\sudoku.cpp(12) : see declaration of 'Board'
1>..\..\..\..\NU\sudoku.cpp(133): error C2228: left of '.fromFile' must have
class/struct/union
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
請問有人知道是怎麼一回事嗎?
我查過書都找不到問題在哪。
拜託了...謝謝!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 165.124.211.107
→
04/10 14:42, , 1F
04/10 14:42, 1F
→
04/10 19:35, , 2F
04/10 19:35, 2F
→
04/12 08:42, , 3F
04/12 08:42, 3F
→
04/12 12:47, , 4F
04/12 12:47, 4F
→
04/12 14:20, , 5F
04/12 14:20, 5F