您的位置:首页 > 其它

类成员函数如何设为内联函数 inline

2011-11-09 16:54 113 查看
第一种方式将函数定义在类声明中

//Test.h

class Test {

int m_count;

int GetCount(){ return m_count;}

}

GetCount 就是内联函数

第二种方式将函数定义在类声明的外部

//Test.h

class Test {

int m_count;

inline int GetCount();

}

Test::GetCount() {

return m_count;

}

总之函数的定义必须在头文件中!!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: