相关疑难解决方法(0)

什么时候编译器内联C++代码?

在C++中,如果方法是显式声明inline(或在头文件中定义),或者允许编译器在他们认为合适的情况下内联方法,那么这些方法是否只有内联?

c++ compiler-construction optimization inline

18
推荐指数
3
解决办法
8487
查看次数

私人模板功能

我有一节课:

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文件中实现私有模板功能的缺点?

c++ implementation templates private

18
推荐指数
2
解决办法
6272
查看次数