What do these errors mean?

This code is from a slide my teacher posted for us in class, but he took it down before I could double check to make sure I typed it all in right. I have the following errors below..Can someone tell me what they mean and how to fix this? Thanks..

Errors:
[linker error] undefined reference to 'squareByValue(int)'
[linker error] undefined reference to 'squarebyReference(int&)'
Id returned 1 exit status

__________________________________________________

#include <iostream>

using std::cout;
using std::endl;

int squareByValue( int );
void squareByReference( int & );

int main()
{
int x = 2;
int z = 4;


cout << "x = " << x << " before squareByValue\n";
cout << "Value returned by squareByValue: "
<< squareByValue( x ) << endl;
cout << "x = " << x << " after squareByValue\n" << endl;

cout << "z = " << z << " before squareByReference" << endl;
squareByReference( x );
cout << "z = " << z << "after squareByReference" << endl;



system("PAUSE");
return 0;
}
99 times out of 100, "undefined reference" or "unresolved external symbol" errors mean that you are calling a function that has no body.

In this case, your squareByValue and squareByReference functions do not have bodies (or the linker can't find the bodies).

Make sure you defined these functions.
The errors are not caused by your typing, they mean that the linker cannot find the 2 symbols. To resolve the errors, you have to ask your teacher for the codes that define the 2 symbols.
Topic archived. No new replies allowed.