Hello fellow programmers. I have stumbled across a problem while compiling this code. It says undefined reference to 'radiation(int)' . Any ideas to help?
Here is the code:
// Taking damage
// Demonstrates inlining functions
#include <iostream>
int radiation(int health);
usingnamespace std;
int main()
{
int health = 80;
cout<<"Your health is: "<<health<<"\n\n";
health = radiation(health);
cout<<"After radiation exposure, your health is: "<<health<<"\n\n";
health = radiation(health);
cout<<"After radiation exposure, your health is: "<<health<<"\n\n";
health = radiation(health);
cout<<"After radiation exposure, your health is: "<<health<<"\n\n";
return 0;
}
inlineint radiaton(int health)
{
return (health/2);
}
Yes and no. Writing code (and testing it too) is certainly necessary, as compared with just reading a book (or tutorial).
But it is the overall syntax and construction of the program where the effort should be placed. Re-typing everyday English words may help with your literary efforts, but is (in my opinion) subtracting valuable time from the overall learning activity.
I think perhaps also relevant is that the use of copy&paste is a valuable part of the things you should be learning. That is, it is useful to copy user-defined names, and doing so encourages the use of meaningful names, whereas if you had to type every single character, it might be tempting to use single-letter variable names and write cryptic mysterious code.