I'm trying to learn C++,
and I thought I'd start by exploring classes,
so I wrote this:
#include<iostream>
#include<string>
using namespace std;
class user {
public:
string logonName;
string firstName;
string lastName;
int uID;
};
int main(){
user users[2];
int i;
users[0].logonName = "rawrMander";
users[0].firstName = "Rawr";
users[0].lastName = "Mander";
users[0].uID = 0;
users[1].logonName = "nobody";
users[1].firstName = "Nothing";
users[1].lastName = "McNothingson";
users[1].uID = 1;
users[2].logonName = "beak";
users[2].firstName = "Beaky";
users[2].lastName = "McBeakerson";
users[2].uID = 2;
for(i=0;i<=3;i++){
cout<<
users[i].uID<< " -- "<<
users[i].logonName<< ": "<<
users[i].firstName<< " "<<
users[i].lastName<< "\n\n";
}
return 0;
}
it compiles fine (with g++, windows port) but when I try to execute it, Windows tells me that it has encountered an error and needs to close.
What have I overlooked here?