Chinaunix首页 | 论坛 | 博客
  • 博客访问: 178279
  • 博文数量: 89
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 828
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-08 10:44
文章分类
文章存档

2014年(9)

2013年(80)

我的朋友

分类: C/C++

2013-11-20 16:35:16

使用内臵函数可以节省运行时间,但却增加了目标程序的长度? 因此一般只将规模很小声明为内臵函数。不能使用复杂控制语句,如switch 和while循环


具体实例:


[cpp] view plaincopy
#include  
#include  
  
using namespace std;  
  
class Student  
{  
private:  
    string _name;  
    int _num;  
public :  
    Student(string str,int num):_name(str),_num(num){}  
    inline void getValue();  
};  
inline void Student::getValue(){  
    cout<<"name :"<_name<         <<"num  :"<_num<     }  
  
int main(){  
    Student stu("buyingfei",100);  
    stu.getValue();  
    return 0;  
}  


阅读(392) | 评论(0) | 转发(0) |
0

上一篇:C++ 友元

下一篇:先给Java菜鸟的字符串

给主人留下些什么吧!~~