線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:712
推到 Plurk!
推到 Facebook!

compile 問題

尚未結案
woods
一般會員


發表:11
回覆:8
積分:3
註冊:2003-10-14

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-28 16:27:06 IP:140.130.xxx.xxx 未訂閱
我用gcc去編譯,不知道這樣的連結有錯誤嗎  結果如下  那大概是錯誤在哪裡呢 
 
In file included from MPIGAGeneticAlgorithm.cpp:15: 
MPIGAGeneticAlgorithm.h: In method 
`MPIGAGeneticAlgorithm::~MPIGAGeneticAlgorithm ()': 
MPIGAGeneticAlgorithm.h:36: parse error before `[' 
MPIGAGeneticAlgorithm.cpp: In method `void 
MPIGAGeneticAlgorithm::buildPrecedenceArray ()': 
MPIGAGeneticAlgorithm.cpp:361: `size' undeclared (first use this 
function) 
MPIGAGeneticAlgorithm.cpp:361: (Each undeclared identifier is reported 
only once for each function it appears in.) 
MPIGAGeneticAlgorithm.cpp:374: `x' undeclared (first use this function)
我想大概是size 跟x沒有宣告 但是我在cpp檔裡的void xxxx{int size; int x } 還是會有錯誤那大概是哪裡錯誤呢
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-01 10:10:03 IP:211.76.xxx.xxx 未訂閱
引言: 我想大概是size 跟x沒有宣告 但是我在cpp檔裡的void xxxx{int size; int x } 還是會有錯誤那大概是哪裡錯誤呢
請問 void xxxx{int size; int x } 是什麼?函式不應該是
void xxxx(int size,int x)
{
  // 程式
}
像您這樣的問題,資料太少,別人不容易幫您的, 可能的話,把您有問題的地方獨立出來測試,如果還有問題, 再把相關的 code post 上來,別人才容易看懂您的問題, 否則,只說 compile 後有問題,如果是還沒到 link 之前就有問題,都是語法上的問題,我只能說,多多看一下書吧 <>沒空更新的網頁... href="http://dllee.adsldns.org">http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com
woods
一般會員


發表:11
回覆:8
積分:3
註冊:2003-10-14

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-11-03 14:00:48 IP:140.130.xxx.xxx 未訂閱
引言: [quote] 我想大概是size 跟x沒有宣告 但是我在cpp檔裡的void xxxx{int size; int x } 還是會有錯誤那大概是哪裡錯誤呢
請問 void xxxx{int size; int x } 是什麼?函式不應該是
void xxxx(int size,int x)
{
  // 程式
}
像您這樣的問題,資料太少,別人不容易幫您的, 可能的話,把您有問題的地方獨立出來測試,如果還有問題, 再把相關的 code post 上來,別人才容易看懂您的問題, 否則,只說 compile 後有問題,如果是還沒到 link 之前就有問題,都是語法上的問題,我只能說,多多看一下書吧 抱歉我會改善的 上面的問題原來是用錯了;號 可是還是有宣告上的問題 看不懂還請多指教 < class="code"> 標頭檔 宣告大概如下 MPIGAGenome** bestArray; /* This will hold the best * genomes found from each population */ /* This sets up the precedenceArray based on current neighborhood size */ void buildPrecedenceArray(); private: unsigned int fmigration; //This is the frequency of migration unsigned int tmigrations; //This is the number of migrations so far unsigned int nmigrate; //This is the number of specimens to migrate unsigned int npopulations; //This will be set to the number of nodes. unsigned int rank; //This will hold the MPI Rank of the //The system the object is instantiated on. unsigned int neighs; //The number of demes in my neighborhood. MPIGAMigrationType migrationType; //What type of migration are we using? MPIGAReplacementType replacement; //What migration policy are we using? GAGeneticAlgorithm* gaalgorithm; //A genetic algorithm from GALib //is pointed at by this. int ** precedenceArray; /* This is a matrix of integers that will be * used for figuring out migration ordering * in STEPPINGSTONE migration. */ MPIGAGenome* best; /* The best found in any population */ .cpp檔的宣告如下 void MPIGAGeneticAlgorithm::buildPrecedenceArray(){ if (precedenceArray==NULL){ precedenceArray = new int[size][neighbors()]; } //Set the array to something other than 0 or 1; for(int i = 0; i 能幫我看看哪裡錯了嗎
dllee
站務副站長


發表:321
回覆:2519
積分:1711
註冊:2002-04-15

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-11-08 23:33:45 IP:211.76.xxx.xxx 未訂閱
引言:MPIGAGeneticAlgorithm.cpp: In method `void MPIGAGeneticAlgorithm::buildPrecedenceArray ()': MPIGAGeneticAlgorithm.cpp:361: `size' undeclared (first use this function)
→ 不會是英文看不懂吧 → 就是 >< face="Verdana, Arial, Helvetica">引言:MPIGAGeneticAlgorithm.cpp:361: (Each undeclared identifier is reported only once for each function it appears in.) → 看不懂 <>< face="Verdana, Arial, Helvetica">引言:MPIGAGeneticAlgorithm.cpp:374: `x' undeclared (first use this function) → 就是 x 這個變數沒有宣告呀! 我猜想,這個程式應該是別人的吧... 如果是附書範例,那您應該是沒有 Key 完整,如果是別人的程式,那應該是原來就有問題了,或是您改出問題了... 另外, MPIGAGeneticAlgorithm 應該是一個物件,但由 .h 檔看不出來... 目前您 post 出來的錯誤,我只能說是基本語法的問題,還是請您多看看基本入門的書吧,否則,愈改問題可能愈多。 沒空更新的網頁... http://dllee.ktop.com.tw C及指標教學,計算機概論,資訊管理導論... http://dllee.adsldns.org 介紹Shells,LiteStep,GeoShell....
------
http://www.ViewMove.com
系統時間:2024-06-27 2:33:00
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!