Question Regarding Pure Virtual

I am currently studying off a book and I believe I am following the exact syntax that the book provides. However, the code is giving me an error message and I'm not quite sure what to make of it. Below is the error that it gives me. Any idea how to fix this? And how would I declare the body of the prototype in my .cpp file? For example, Ship::draw(){}? Thank you in advance for your help!

In file included from mainship.cpp:2:0:
ship.h:12:3: error: conflicting return type specified for ‘virtual int Ship::draw()’
draw();
^
ship.h:7:16: error: overriding ‘virtual void Drawable::draw()’
virtual void draw() = 0;
^
In file included from ship.cpp:2:0:
ship.h:12:3: error: conflicting return type specified for ‘virtual int Ship::draw()’
draw();
^
ship.h:7:16: error: overriding ‘virtual void Drawable::draw()’
virtual void draw() = 0;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef SHIP_H
#define SHIP_H
using namespace std; 

class Drawable{
	public:
		virtual void draw() = 0; 
}; 

class Ship:public Drawable{
	public:
		virtual draw(); 
}; 
 

#endif 
Last edited on
Add void before draw() on line 12.
Topic archived. No new replies allowed.