看板 MATLAB 關於我們 聯絡資訊
我的matlab版本是2008a 64bit 作業系統是win7 64bit 使用的編譯器是visual c++ 2008 剛開始跑版上M文給的範例(Hello World)當然是可以compile 但因為我比較習慣用C++寫 所以加了include<iostream> 改用cout 結果竟然出現compile失敗 以下是我的程式碼 #include <iostream> #include"mex.h" using namespace std; void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { cout << "Hello! World!\n"; } 請問這樣打有什麼問題嗎? 還是真的不能compile C++ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.170.155 ※ 編輯: kuenya 來自: 140.113.170.155 (05/05 00:09)
qwerty9876c:可以 看你的結尾是.cpp 還是 .c 05/05 16:12
qwerty9876c:我之前有遇過 用.c的檔案 寫物件導向 不會compile 05/05 16:13
kuenya:謝謝樓上,我compile過了! 不過執行的時候竟然沒cout..怪怪 05/05 17:13
qwerty9876c:mexPrintf 改用這一個試試看 05/06 09:05
math99:印像中 matlab 不認識 cout ... 05/06 12:38
yan12125:C++可以,不過我是ubuntu x64/GCC... 05/06 22:31
kuenya:謝謝各位 我想應該只是matlab剛好不認識cout 普通C++還是可 05/07 16:40
kuenya:mexprintf和printf似乎是一樣的 只是不用include header檔 05/07 16:42
kuenya:他是直接用mex.h內的 不用讀整個stdio library 05/07 16:44