My background is in C# and C. I'm learning the syntax for C++. Wondering which code goes in the *.h files and which in the *.cpp files.
Initially I was placing variable declarations and method signatures in the *.h file, and method code in the *.cpp file.
Then I came across this case where moving method SetFunc to the *.cpp file didn't work. I had to put the SetFunc method code in the *.h file, and I was wondering why that was. When should I put the method definition in the *.cpp file and when in the *.h file?
Traditionally, unless you want to abuse preprocessor directives, all declarations and template definitions go into header files whereas all definitions of non-templates go into source files.
stdafx.h is a non-standard extension known as pre-compild headers supported by some compilers (most notably MSVC). I recommend not using it.