I have a file A.cpp which has the following lines:
#include"B.h"
int main(int argc, char **argv)
{
...
char *input_file = *argv;
B *definition = new B(input_file);
...
}
In B.h, I have the following:
class B
{
public:
// Constructors
B(void);
B(const char *filename);
...
}
When I compile, I get the following error: undefined reference to 'B::B(char const*)'
Any suggestions on how to fix?
Thanks.
You need a definition for
B::B(char const *). You have provided only a declaration forB::B(char const *), and the Linker is complaining that it can’t actually find that function.