Quote Originally Posted by laserlight
Oh, that's just a typographical error on your part. You defined AbstructGroup, but really wanted to define AbstractGroup.
so silly of me.

Here is the fixed code:

AbstractGroup.h:
Code:
#ifndef ABSTRACTGROUP_H_
#define ABSTRACTGROUP_H_

template<class Type>
class AbstractGroup {
public:
	virtual Type	element(int) const = 0;
	virtual int	order() const = 0;
	virtual Type	inverse(const Type& x) const = 0;
	virtual Type	operation(const Type& left, const Type& right) const = 0;
};

#endif /*ABSTRACTGROUP_H_*/
D3.h:
Code:
#ifndef D3_H_
#define D3_H_

#include <map>
#include <string>
#include <algorithm>
#include "AbstractGroup.h"
using namespace std;

class D3 : public AbstractGroup<string> {
//...
};
#endif /*D3_H_*/
Main.cpp:
Code:
#include "D3.h"

#include <iostream>
using namespace std;

int main()
{
	D3 d3;

	AbstractGroup<class Type> *g = (AbstractGroup<class Type> *) &d3;
	cout << g->order() << endl;
	cout << g->inverse(string("123")) << endl;

	return 0;
}
mingw warns in the line where g->inverse() is used:

no matching function for call to `AbstractGroup<Type>::inverse(std::string)' MingWPractice Main.cpp

as expected.
Quote Originally Posted by Graham
You could make an untemplated base class for AbstractGroup, but that wouldn't gain you anything because it would have no sensible behaviour.

maybe if you described your high-level requirements we might be able to come up with a solution.
All I want is to use the "interface" defined in AbstractGroup. There will be several classes that will use the interface. All of these derived classes (like D3) must have four functions in common: the pure virtual functions in AbstractGroup.

I also need to select a particular instance chosen by the user. So I would like to use AbstractGroup *g which cannot be specific, like AbstractGroup<string>* because the user may choose a derived class instance base on AbstractGroup<int>. Is there any alternative to use an abstract template class?