So you know how it's best to always try to Declare your regular functions before int main(), then define the functions at the very end of the program like:
1 2 3 4 5 6 7 8 9 10
int add(int x, int y);
int main()
{
add(5,6);
return 0;
}
int add(int x, int y)
{
return x+y;
}
Well, could you do that as well with functions of classes? Is it needed? And, if so, how would you do it? For example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class soldier
{
public:
void attack(int number);
health;
}
int main()
{
soldier Tom;
tom.attack(10);
return 0;
)
soldier::attack(int number)
{
health -= number
}
Okay, I know my code doesn't make sense but that's not the point. My question is, should we define the member functions at the end of the program like normal functions? And if so, is this the right way to do it?
Thanks Disch! Now I remember that from my book, except that my book didn't teach us how to combine those files, but I'll figure it out :). Thanks again, Disch !