作者teybend (圈圈)
看板C_and_CPP
標題[問題] include 新的cpp debug 會出現問題
時間Thu Jan 28 15:47:53 2016
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VS2013
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
opencv
問題(Question):
新建的cpp 要正確debug 都要重建專案
否則會顯示之前dubug的結果
下面範例 第一次debug 會正確 顯示 Test1 Test1
但若把a.cpp b.cpp cout 都改 Test2
在debug 會顯示 Test2 Test 1 而不是 Test2 Test2
唯有重建後才會都正確顯示 ? 但我不太懂這問題
後來我有測試接下來建的cpp 都會這樣 但不知道哪裡出問題?
*[36m餵入的資料(Input):*[m
*[36m預期的正確結果(Expected Output):*[m
*[36m錯誤結果(Wrong Output):*[m
*[36m程式碼(Code):(請善用置底文網頁, 記得排版) *[m
main.cpp
#include "global.h"
#include "a.cpp"
#include "b.cpp"
int main()
{
a ob1;
b ob2;
a.init();
b.init();
return 0 ;
}
a.cpp
#include "global.h"
class a
{
private :
Mat img;
int height, width;
public:
void init( )
{
cout << "Test1" << endl;
}
};
b.cpp
#include "global.h"
class b
{
private :
Mat img;
int height, width;
public:
void init()
{
cout << "Test1" << endl;
}
};
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.193.236
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1453967276.A.189.html
→ Caesar08: 請問你的global.h裡面有甚麼? 01/28 16:02
推 LPH66: 你為什麼要 include a.cpp b.cpp? 01/28 17:04
→ LPH66: 共同的 class 定義應該要寫在 .h 裡 01/28 17:05
→ teybend: global include共同需要的,using space #define 01/28 17:41
→ teybend: 不同class處理不同事情,所以寫在不同cpp,不懂寫在.h差別 01/28 17:43
→ shadow0326: 宣告和定義分開 01/28 18:08
→ teybend: 什麼意思 差別是 ? 01/28 19:09
→ teybend: 先謝謝 不過我不是編譯錯誤 我是好像編譯連結出現問題 01/28 21:31
→ teybend: 另外我書上介紹 同個函數 要使用 則命名.h 不然彼此獨立 01/28 21:32
→ teybend: 通常都命名.cpp 01/28 21:32
→ teybend: 另外global include define我習慣寫在同一個.h 這樣是不 01/28 21:34
→ teybend: 好嗎? 01/28 21:34