Hello, I'm facing a rather strange problem that I need help on solving... So when I instantiate a derived class (HomePC, GamingPC or WorkstationPC) from the base abstract class (PC), I get segmentation fault message. What's even more strange is that, on the IDE (Code::Blocks) the program runs fine the first 2 times I try to instantiate, but the 3rd time, instead of crashing, the while loop terminates. The crash occures on Putty though, but not on the IDE?
I uploaded the code on pastebin because it's too big to fit here.
Instatiation that causes the crash happen on lines 306, 311 and 316.
You should also post what you expect people to type in to get the thing to work / crash.
Yeah you are right, the crashes occur when you type "new", then one of the three: homepc, gamingpc or workstationpc and then any name, for example:
new gamingpc myPC
If I execute that command 3 times on the IDE, the while loop terminates (which it shouldnt because it doesnt even have an ending condition), and on Putty it crashes with segmentation fault message.
At the point you call the base class, model is uninitialised.
What do you mean that it's not initialised? I thought calling the base class there uses the PC::model variable which is defined