2015-06-20 20 views
0

我不知道我在做什麼錯誤!C++「沒有這樣的文件或目錄」,請。我有包含的標題! (C++ Primer)

我已經定義的頭文件:項目 - >構建選項 - >搜索directories->反編譯>補充說明我的頭文件所在的路徑...

我使用的代碼塊。

我不知道什麼是錯的!

#include <iostream> 
#include "Sales_item.h" 

using namespace std; 

int main() 
{ 
    Sales_item book; // Reads ISBN, number of copies sold and sales price 
    cin >> book; // Write ISBN, number of copies sold, total revenue, and avg. price 
    cout << book << endl; 
    return 0; 
} 
+3

複製你的問題從選項卡«構建輸出»充分調用編譯器。它就像'g ++ main.cpp ...',*(下面你還會看到構建錯誤)*。 –

回答

0

簡單的訪問Code :: Blocks維基將解決你的問題。

的過程:

- Right click on the project then select Build options - Select the directories tab - Add the required paths for compiler and linker. - Add your specific libraries in the linker tab. - Pay attention to project settings and target settings.

+0

不知道我在做什麼錯。我遵循了這些步驟,但它仍然給我這個錯誤。我是否將文件放在正確的文件夾中?我確定我是因爲我在文件夾中有頭文件。 – Seeist

+0

謝謝,這已解決。我現在使用CodeLite而不是CodeBlocks。 – Seeist

0

嘗試< Sales_item.h>而不是 「Sales_item.h」。不確定CodeBlocks,但使用「」通常意味着路徑位於同一目錄中,而<>表示該路徑在項目設置中描述。

+0

不完全正確,並且「」語法應該在故障時退回到<>語法。請參閱http://stackoverflow.com/a/77092/1614219 – dureuill

+0

我的意思是平時的一般情況 - 不知道CodeBlocks如何重寫它 – Tezkatlipoka

+0

這是在C++標準中定義的,所以codeblocks不應該干擾。看到我鏈接的答案。 – dureuill

0

如果你的問題是因爲<iostream>, 轉到Settings -> Compiler... -> Global compiler settings -> Linker settings然後添加目錄文件夾的路徑到文件夾

如果你的問題是因爲"Sales_item.h",確保Sales_item.h被放置在與此相同的目錄(main.cpp我猜)

相關問題