it seem , i have a problem to get from template derive class into variables which found on base class.
the error i get is :
Error C2065 'a': undeclared identifier
Error C2065 'b': undeclared identifier
here the code:
--->>base.h
#ifndef _BASE_H
#define _BASE_H
template <class T>
class base
{
T a, b;
public:
T getMull1();
base(T q,T W);
~base();
};
#include "base.cpp"
#endif
-->> base.cpp
#include "stdafx.h"
#include "base.h"
#ifndef BASE_IMPL__
#define BASE_IMPL__
template<class T>
T base<T>::getMull1()
{
return a * b;
}
template<class T>
base<T>::base(T q, T W)
{
this->a = q;
this->b = W;
}
template <class T>
base<T>::~base()
{
}
#endif
-->>derive1.h
#ifndef _DERIVE1_H
#define _DERIVE1_H
#include "base.h"
template <class T>
class derive1 :
public base<T>
{
public:
T getMull();
derive1(T q, T W);
~derive1();
};
#include "derive1.cpp"
#endif
-->>derive1.cpp
#include "stdafx.h"
#include "derive1.h"
#ifndef DERIVE1_IMPL__
#define DERIVE1_IMPL__
template<class T>
T derive1<T>::getMull()
{
return a*b;
}
template<class T>
derive1<T>::derive1(T q, T W):base<T>(q,W)
{
}
template<class T>
derive1<T>::~derive1()
{
}
#endif
-->>main
#include "stdafx.h"
#include "derive1.h"
derive1<int> myDerive(1,4);
int main()
{
int ans = myDerive.getMull1(); //working fine on the base
ans = myDerive.getMull(); // not working
return 0;
}
please help me to solve this issue.