Hi! I'm trying to run this code, nevertheless complier keeps on telling me further errors...any idea? What kind of theme should i be looking for in a book, in order to solve my answer? Thanks a lot!!!
#include <iostream>
using namespace std;
template<class T>
class A{
protected:
T a;
public:
void setA(T);
T getA();
};
template<class T>
class B : public A<T>{
public:
T bGetA();
void bSetA(T);
};
template<class T>
T bGetA(){
return a;
}
template<class T>
void bSetA(T a){
this->a = a;
}
int main(){
B b;
b.bSetA();
cout << b.GetA()<<endl;
return 0;
}
HerenciaT.cpp: In function ‘T bGetA()’:
HerenciaT.cpp:32: error: ‘a’ was not declared in this scope
HerenciaT.cpp: In function ‘void bSetA(T)’:
HerenciaT.cpp:37: error: invalid use of ‘this’ in non-member function
HerenciaT.cpp: In function ‘int main()’:
HerenciaT.cpp:41: error: missing template arguments before ‘b’
HerenciaT.cpp:41: error: expected ‘;’ before ‘b’
HerenciaT.cpp:42: error: ‘b’ was not declared in this scope