Cannot move virtual function outside header
c++, compilation, function, syntax, visual-c++
Solution
As it says, you can't have `virtual` on the function definition outside the class, as per §7.1.2:
The `virtual` specifier shall be used only in the initial declaration of a non-static class member function
Keep the `virtual` on the declaration and remove it from the definition. So in the header file:
class SoundMixerSub : ...
{
// ...
virtual void SetFilters(const MixerFilter&);
// ...
};
Then in the implementation file:
void SoundMixerSub::SetFilters(const MixerFilter& f)
{
// ...
}
Problem
I have a C++ class header that defines many functions inline. I want to move these functions outside the header and into a seperate `.cpp` file to speeden up the compile. Although I can move normal functions into a seperate file and keep only the function deceleration in the header, when I try to move virtual functions into the `.cpp` I get the following error: Error 2 - error C2723: 'virtual' storage-class specifier illegal on function definition How do I do that? The function is as follows: ``` virtual void SoundMixerSub::SetFilters(const MixerFilter& f) { .... } ```