![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 | |
|
Professional Programmer
|
.H or .cpp?
I have a class called Monster, now what I have is an array of 5 monsters, because there are 5 different monsters in my program.
Monster array[5];
array[0].SetName("monster1");
array[1].SetName("monster2");
array[2].SetName("monster3");
array[3].SetName("monster4");
array[4].SetName("monster5");
array[0].SetDamage(12);
array[1].SetDamage(15);
array[2].SetDamage(16);
array[3].SetDamage(3);
array[4].SetDamage(22);I know that is horrible code, mine doesn't actually look like that though. I am just wondering, if you are only using the file to set the data members for the array, should I use a .cpp file or a header? I'm thinking a .cpp file is the way to go, but I am also under the impression you should do "#include "array.cpp"" type declarations, so I would need a header in association to simply refer to that .cpp file. EDIT: Or, would I just set each value for each array in the Monster.cpp file, which holds all the member functions?
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|