這段代碼有什麼問題?爲什麼1 compilator說它確定並運行它,但來自微軟的其他人則大聲疾呼。我什至不能找到錯誤的錯誤的東西是錯誤的。DEV C++ compiless但Visual Studio不會
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
class Person
{
private:
static const int LIMIT = 256;
string lname;
char fname[LIMIT];
public:
Person() { lname = "";fname[0] = '\0'; }
Person(const string & ln , const char* fn = "HejTy") { lname=ln; strncpy(fname,fn,LIMIT);}
void Show() const { cout << "nieformalnie: " << fname << " " << lname << endl; }
void FormalShow() const { cout << "formalnie: " << lname << " " << fname << endl; }
};
int main(){
Person one;
Person two("StaszeK");
Person three("JACEK", "Placek");
one.Show();
cout << endl;
one.FormalShow();
two.Show();
cout << endl;
two.FormalShow();
cout << endl;
three.Show();
cout << endl;
three.FormalShow();
cout << endl;
system("PAUSE");
return 0;
}
什麼是錯誤信息? – Mahesh 2013-02-22 19:56:37
「我甚至都找不到錯誤的錯誤。」忽略999999999最後一行錯誤消息。第一個總是重要的一個。因爲這是編譯器第一次遇到。以下可能是廢話取決於該錯誤。 – stefan 2013-02-22 20:03:55
Dev C++使用與最新C++標準不兼容的舊版本的MinGW編譯器,我建議您將IDE更改爲任何較新版本(例如Code :: Blocks使用較新的MinGW)。 – micnyk 2013-02-22 20:07:55