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 回答