Chinaunix首页 | 论坛 | 博客
  • 博客访问: 16199
  • 博文数量: 14
  • 博客积分: 245
  • 博客等级: 二等列兵
  • 技术积分: 180
  • 用 户 组: 普通用户
  • 注册时间: 2012-12-28 13:45
文章分类

全部博文(14)

文章存档

2013年(9)

2012年(5)

我的朋友

发布时间:2013-01-04 13:51:38

常成员函数含义是通过该函数只能读取同一类中的数据成员的值,而不能修改它。 特点就是将const写在最后面。   class Point   {   public:   int GetX() const; //声明常成员函数   int GetY() const;   void SetPt (int, int);   void OffsetPt (int, int);   private:   int xVal, yVal;   }; ......【阅读全文】

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

发布时间:2013-01-04 10:53:17

#include "stdafx.h"#include <iostream>using namespace std; template <class T> void swap_pri(T& a, T& b){ T c; c=a; a=b; b=c;} int _tmain(int argc, _TCHAR* argv[]){ int a1 = 5; int b1 = 3; swap_pri(a1,b1); cout<< "a = "<<a1<......【阅读全文】

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

发布时间:2013-01-01 23:06:23

内联函数从源代码层看,有函数的结构,而在编译后,却不具备函数的性质。编译时,类似宏替换,使用函数体替换调用处的函数名。一般在代码中用inline修饰,但是能否形成内联函数,需要看编译器对该函数定义的具体处理。   #include "stdafx.h" #define swap1(a,b)  {int c;c=a;a=b;b=c;}#define swap2(a,b)  {a^=b,b^=a;a^=b;} inline void swap3(int &a,int &b);void swap3(int &a,int &b){&......【阅读全文】

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

发布时间:2013-01-01 20:50:23

#include "stdafx.h" #define swap1(a,b)  {int c;c=a;a=b;b=c;}#define swap2(a,b)  {a^=b,b^=a;a^=b;} int _tmain(int argc, _TCHAR* argv[]){ int a1=3; int b1=5; swap1(a1,b1); printf("a = %d, b= %d \n",a1,b1);  int a2=3; int b2=5; swap2(a2,b2);  &n......【阅读全文】

阅读(144) | 评论(0) | 转发(0)
给主人留下些什么吧!~~
留言热议
请登录后留言。

登录 注册