在C++中,如果方法是显式声明inline(或在头文件中定义),或者允许编译器在他们认为合适的情况下内联方法,那么这些方法是否只有内联?
我有一节课:
章
class C {
private:
template<int i>
void Func();
// a lot of other functions
};
Run Code Online (Sandbox Code Playgroud)
C.cpp
// a lot of other functions
template<int i>
void C::Func() {
// the implementation
}
// a lot of other functions
Run Code Online (Sandbox Code Playgroud)
我知道,在cpp文件中移动模板实现并不是最好的主意(因为它不会从其他cpp中看到,它可能包含带有模板声明的标头).
但私人功能怎么样?谁能告诉我是否有在.cpp文件中实现私有模板功能的缺点?