so i've got this class called room that i'm testing on its own. i've got 3 files, room.h, room.cpp which has the definitions, and then i have the driver program to test the class:
Code:// room.h // #include <iostream> using namespace std; class room { public: void showRoom() const; // displays the current room room(); // default constructor ~room(); // default destructor private: string description; int status; };Code:// room.cpp // #include <string> #include "room.h" void room::showRoom() const { system("cls"); cout << description; } room::room() { description = "There is no description of this room."; status = 0; } room::~room() { }thats my code so far. it works and everything, i'm just wondering what's the best way to make use of the header file? i mean, if there are benefits to putting all the includes in the header, or if it's better to keep them separate and declare them for each .cpp file... i think you know what i'm getting at. just curious if there's a generally used standard or if it's all up to personal preference. thanksCode:// room driver.cpp // #include "room.h" int main() { room emptyRoom; emptyRoom.showRoom(); cin.get(); return 0; }



LinkBack URL
About LinkBacks


