Specializing a class template means that whenever that class is instantiated with that specific specialized type, it will use the specialized definition. That is the reason you got the first undefined error. But when you added the specialized update function but did not defined it, instead assumed it to use the default one, then that caused the second error message you got because it does not use the default one as you wished, but instead tries to look for the specialized Update definition. I think what you want todo is a little bit more abstraction like so:
//This will hold all function common to template param for State class
template<typename Container, typename Specific>
struct CommonStateDefinition{
void Update(StructData const &lData){
std::cout<<"In CommonStateDefinition::Update" << endl;
}
};
template<typename Container, typename Specific>
struct State{
CommonStateDefinition<Container,Specific> m_stateImpl;
void Update(StructData const &lData){
std::cout << "In State::Update" << endl;
m_stateImpl.Update(lData);
}
}
template<>
class State<ChemicalVars, Chemicals*>{
CommonStateDefinition<ChemicalVars,Chemicals*> m_stateImpl;
//use the common update via delegation
void Update(StructData const &lData){
std::cout << "In State<ChemicalVars,Chemicals*>::Update" << endl;
m_stateImpl.Update(lData);
}
//add other specialized function
}