My program calls for me to create a base class Clock, a derived class AccurateClock, and to access them in main, but I'm getting two "LNK2019: unresolved external symbol" errors. I really don't know what to do to fix those. Any help is appreciated!
I have 5 different code sections, so I'll just post the main and the 2 .cpp for right now.
This is my main, Clock.cpp, and AccurateClock.cpp. The main is supposed to feed numbers into the classes and print them on screen.
Usually, that error means that you've declared some function in the class, but haven't defined it. As vlad said, it might be that you didn't define it, or maybe you didn't compile the .cpp file that contains the definition.
Specific error lines are useful if that doesn't solve your problem.
Pass8Q2.obj : error LNK2019: unresolved external symbol "public: __thiscall AccurateClock::AccurateClock(void)" (??0AccurateClock@@QAE@XZ) referenced in function _main
Pass8Q2.obj : error LNK2019: unresolved external symbol "public: __thiscall Clock::Clock(void)" (??0Clock@@QAE@XZ) referenced in function _main
#ifndef Clock_H
#define Clock_H
#include<iostream>
usingnamespace std;
class Clock
{
public:
int hour;
int minute;
Clock();
Clock(int h, int m)
{
int hour = h;
int minute = m;
}
virtualvoid printTime();
void setHour(int);
void setMinute(int);
int getHour() const;
int getMinute() const;
};
#endif
Oh, wow, sorry about that. I thought that when you write that the compiler automatically sets the body to NULL. Turns out you're not supposed to write it at all...sorry, and thanks!