相关疑难解决方法(0)

内联和良好实践

可能重复:
何时使用内联函数和何时不使用它?

我已经看到许多源代码使用与inline指令不同的语法.

namespace Foo
{
    class Bar
    {
        public:

            // 1 - inline on the declaration + implementation
            inline int sum1(int a, int b) { return a + b; }

            // 2 - inline on template declaration + implementation
            template <typename T>
            inline T sum2(T a, T b) { return a + b; }

            // 3 - Nothing special on the declaration...
            int sum3(int a, int b);
    };

    // 3 - But the inline directive goes after …
Run Code Online (Sandbox Code Playgroud)

c++ coding-style inline

4
推荐指数
1
解决办法
2002
查看次数

标签 统计

c++ ×1

coding-style ×1

inline ×1