I am just practicing using classes so that I better understand how they work and such but I have ran into an error which I do not understand. Here is my code-
The compiler error-Code:#include <iostream> using namespace std; class Teacher { public: Teacher(); void SetRoomNumber(int RoomNum); int GetRoomNumber(); private: int RoomNumber; } Teacher::Teacher { SetRoomNumber(0); } Teacher::SetRoomNumber() { RoomNumber = RoomNum; } Teacher::GetRoomNumber() { return RoomNumber; } int main() { Teacher Stone, Hill; cout << Stone.GetRoomNumber(); cout << Hill.GetRoomNumber(); Stone.SetRoomNumber(219); Hill.SetRoomNumber(221); cout << Stone.GetRoomNumber(); cout << Hill.GetRoomNumber(); return 0; }
I am pretty sure it isn't my code by the way the error code is. But I would appreciat some help.fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
EDIT: Also when you create your own constructor, is it a good habit to create a destructor even if it takes no action?



LinkBack URL
About LinkBacks


