Reputation: 5931
What's wrong in this code? Why 1 compilator says its ok and run it but other , from Microsoft, shout about tons of errors. I can't even find thing is wrong coz bilion of linies of error.
#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;
}
Upvotes: 0
Views: 596
Reputation: 34625
You are missing the header <string>
. Include it.
#include <string>
Upvotes: 1