How to inherit a template class??

I am trying to inherit the contents of one template class from one header file, to another template class which is in a separate header file.

Here is what I have.


In header file 1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef LISTTYPE__H
#define LISTTYPE__H

#include <iostream>

template <typename T>
class ListType {
public:
	ListType(size_t = 10);
	ListType(const ListType<T>&);
	~ListType() : virtual;
	operator=(const ListType<T>&) : const ListType<T>&;
	virtual bool insert(const T&) = 0;
	virtual bool eraseAll();
	virtual bool: erase(const T&) = 0;
	size_t size() const;
	bool empty() const;
	bool full() const;
	void print() const;
	size_t cap() const;
	friend std::ostream& operator << (std::ostream&, const ListType&);
// The important of protected is to restrict access to it's data from main. Friends of this class can access its data.
protected:
	int* list;
	size_t capacity;
	size_t count;

};

#endif 


In header file 2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef OLISTTYPE__H
#define OLISTTYPE__H

#include "ListType.h"

template <typename T>

class OListType:ListType<T>{
public:
	OListType(size_t = 10);
	bool insert(const int); 
private:
	void insert_item(const int);
};

#endif 

The error I am getting in my main.cpp file is:

argument list for class template: "OListType" is missing. not sure :S
Last edited on
Instead of defining a variable like so:

OListType o;

define it: OListType<int> o;

This is an issue with code instantiating an OListType. Not with any of the code you've shown.
thank you sir, solved.
Topic archived. No new replies allowed.