内联函数于非内联函数的区别
njjn 2003-01-15 05:42:02
class Rectangle{
int width,height;
public:
Rectangle(int w=0,int h=0);
int getwidth() const;
void setwidth(int w);
int getheight() const;
void setheight(int h);
};
inline Rectangle::Rectangle(int w,int h):width(w),height(h){}
inline int Rectangle::getwidth() const{return width;}
inline void Rectangle::setwidth(int w){width=w;}
inline int Rectangle::getheight() const{return height;}
inline void Rectangle::setheight(int h){height=h;}
void main(){
Rectangle r(19,47);
int iheght=r.getheight();
r.setheight(r.getwidth());
r.setwidth(r.getheight());
}
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
class Rectangle{
int width,height;
public:
Rectangle(int w=0,int h=0);
int getwidth() const;
void setwidth(int w);
int getheight() const;
void setheight(int h);
};
Rectangle::Rectangle(int w,int h):width(w),height(h){}
int Rectangle::getwidth() const{return width;}
void Rectangle::setwidth(int w){width=w;}
int Rectangle::getheight() const{return height;}
void Rectangle::setheight(int h){height=h;}
void main(){
Rectangle r(19,47);
int iheght=r.getheight();
r.setheight(r.getwidth());
r.setwidth(r.getheight());
}
请叫各位 这到底有什么区别
可否加入输出语句看看结果的不同
我自己加的结果也没什么区别?
解释的清楚明白就立即给分
谢谢