linux complier c++ string - Linux

Table of Contents

※ [本文轉錄自 C_and_CPP 看板]

作者: b60413 (None) 看板: C_and_CPP
標題: [問題] linux complier c++ string
時間: Thu Mar 26 15:40:52 2009

今天我嘗試在linux上編譯自己寫的一小段程式碼

結果編譯一直錯誤並且顯示"錯誤:「string」 沒有命名一個類型"

我查了google以後 他說可能是沒有include string.h這個標頭

於是我又去修改我的程式碼並且加入string.h這個標頭檔

但是還是一直無法使用....不知道到底是哪裡有寫錯....

還請版友幫忙糾正一下 謝謝

//A.cpp 這是一個測試用的class
#include <iostream>
#include <string>
#include "A.h"

using namespace std;

A::A()
{
cout<<"call constructor"<<endl;
a="aa";
}

//main.cpp 這是主要的程式碼片段
#include <iostream>
#include <string>
#include "A.h"

using namespace std;

int main()
{
A b;
return 0;
}

--

All Comments

Sandy avatarSandy2009-03-29
編譯的錯誤訊息應該一起貼出來
Xanthe avatarXanthe2009-04-03
where A.h? #include<string.h> ?