I cannot seem to figure out what I am doing wrong here. I have a lot more code I am trying to get working, but I get the same errors with this simple code, so I figure I will start there. I am copying this almost directly from the book I am using, so I am totally lost on this one.
Code
#include <iostream>
using namespace std;
class Server
{
public:
Server(char letterName);
};
int main()
{
Server sq('A'), s2('B');
return 0;
}
After this, it will not compile. I get the error:
[Linker Error]Undefined reference to 'Server::Server[char]
[Linker Error]Undefined reference to 'Server::Server[char]
Id returned 1 exit status
I am using DevC++ and it is my only compiler I have. Any help is appreciated.
You have to define what the constructor does. Currently, you are just saying "it exists" (prototyping it), and not defining it, causing the linker to complain.