0

このコードのどこが間違っていますか? なぜ 1 つのコンパイラは問題ないと言って実行するのに、Microsoft の他のコンパイラは大量のエラーについて叫ぶのですか。私は物事が間違っていることを見つけることさえできません。

    #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;
}
4

1 に答える 1

1

ヘッダーがありません<string>。それを含めます。

#include <string>
于 2013-02-22T20:01:30.207 に答える