Abstract class type

Hi,
I have a abstract base class polygon and want to write a pure virtual function to translate my polygon, however I cannot write 'virtual polygon translate(const coords trans)=0' as I will be trying to declare a parameter that has the type of an abstract base class.
What is a way around this?

Thanks for your help :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// ASTRACT BASE CLASS FOR 2D POLYGONS

#ifndef POLYGON
#define POLYGON

using namespace std;

class polygon: public coords {

public:

	// Virtual destructor
	virtual ~polygon(){} //
	
	// Pure virtual function to print info
	virtual void info()=0; 
	
	// pure virtual function to translate polygon
	//virtual polygon translate(const coords trans)=0;

}; // end of base class

#endif POLYGON  


In my triangle class (which inherits the polygon class) the translation function (which works fine) is written as
1
2
3
4
5
6
7
8
	// Function to translate the triangle by a set of coordinates
	triangle translate(const coords trans){
		triangle temp;
		temp.sett1(t1+trans);
		temp.sett2(t2+trans);
		temp.sett3(t3+trans);
		return temp;
	}
Topic archived. No new replies allowed.