Extending templated class, with self referential templated class

Hi cplusplus forum,

I am trying to translate the following java to c++, I'm still a bit new to C++ so I don't understand all the syntax yet.

1
2
3
4
5
interface A<K, V>
{
K getKey();
V getValue();
}

1
2
3
class B implements A<int, B>
{
}

and I'm having some trouble getting the header of class B right.

A.h:
1
2
3
4
5
6
template<class K, class V>
class A
{
K getKey();
V getValue();
};

B.h
1
2
3
4
5
6
7
include "A.h"
class B; //forward declaration
class B : A<int, B>
{
int getKey();
B getValue();
};

Thank you
Last edited on
[code] "Please use code tags" [/code]
¿what errors are you getting?
1
2
3
class foo{
//...
}; //<-- semicolon 


B B::getValue() ¿what do you want to return there?
Thank you, that was it. I've added the code tags in the original post too.
Topic archived. No new replies allowed.