In my opinion that code shouldn't compile at all.
string Computer::AssignCompName(string compname){
ComputerName = compname;
}
string Computer::AssignIP(string IP){
IPAddress = IP;
}
string Computer::AssignDescription(string description){
Description = description;
}
They should look more like this imho:
void Computer::AssignCompName(string compname){
ComputerName = compname;
}
void Computer::AssignIP(string IP){
IPAddress = IP;
}
void Computer::AssignDescription(string description){
Description = description;
}
Note that you'll need to change the return type to
void
in the declaration as well.
If your program behaves weirdly you should try to step through it with the debugger, it will let you execute each code line in a step-by-step kind of manner. Very useful.
As for your code, after making the changes I've suggested above it runs fine on my box, I'm using Visual Studio 2010, what compiler or IDE are you using to build you program?
/Fredrik