Why won't this compile? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why won't this compile?

https://code.sololearn.com/cYVz13DU1DZ3/#cpp I've got a header file here and when I instantiate a Compare class object in the main.cpp it does not compile and treats it as an abstract class even though I've implemented the definitions in the source. Any ideas?

29th Nov 2017, 12:35 AM
Chris
Chris - avatar
3 Answers
+ 2
What's your main function look like?
29th Nov 2017, 12:40 AM
AgentSmith
0
I just put this in main and that's when I get the error int main() { Compare obj1("Chris",5); } Just passing in parameters to the constructor
29th Nov 2017, 1:18 AM
Chris
Chris - avatar
- 1
Because of the virtual functions in Compare. Remove the virtual key word.
29th Nov 2017, 9:40 AM
Timon Paßlick