为什么使用const?采用符号常量写出的代码更容易维护;指针常常是边读边移动,而不是边写边移动;许多函数参数是只读不写的。const最常见用途是作为数组的界和switch分情况标号(也可以用枚举符代替),分类如下:
常变量: const Type 变量名 或 Type const 变量名 //两者相同
常引用: const Type &引用名
常对象:...
分类:
编程语言 时间:
2014-10-09 03:06:27
阅读次数:
165
我们知道每个程序都有它的一套流程结构,而一个经典的程序更是离不开流程控制。这节我来讲解流程控制的各种结构。 结构按一定的顺序执行的叫顺序结构如下所示,直到程序执行完毕退出。,语句1语句2语句3...return 0语句 选择结构 (1)if ~ else 条件语句 (2)switch 多...
分类:
编程语言 时间:
2014-10-07 21:52:44
阅读次数:
291
转载请注明出处:http://blog.csdn.net/lhy_ycu/article/details/39828653
状态模式(State):允许对象在内部状态改变时改变它的行为,对象看起来好像修改了它的类。状态模式说白了就是一个对像有不同的状态,不同的状态对应不同的行为,它其实是对switch case这样的语句的拓展。
封装基类状态的行为,并将行为委托到当前状态。...
分类:
编程语言 时间:
2014-10-06 20:53:30
阅读次数:
297
#include
char get_choice(void);
char get_first(void);
int get_int(void);
void count(void);
int main(){
int choice;
void count (void);
while ((choice =get_choice())!='q')
{
switch(choice)
{...
分类:
编程语言 时间:
2014-10-06 18:06:50
阅读次数:
183
代码: #include?<stdio.h>
#include?<stdlib.h>
void?func(int?n);
int?main(void)?{
int?a;
a?=?10;
func(a);
a?=?20;
func(a);
a?=?30;
func(a);
return?EXIT_SUCCESS;
}
void...
分类:
其他好文 时间:
2014-10-06 12:22:50
阅读次数:
440
#include using namespace std;char const *keyword[]={"do","for","switch","return","while"};int lookup_keyword(const char * const des,char const *keywor...
分类:
其他好文 时间:
2014-10-05 11:22:48
阅读次数:
253
在eclipse cdt中import github的远程项目,操作是import ->Git/projects from git ->Clone URI导入的项目可以switch branch, 但就是不能打开函数的声明,实际上eclipse的一切快捷键都不能用了我看了下导入项目的preferen...
分类:
系统相关 时间:
2014-10-05 01:03:37
阅读次数:
315
1. ps------process status2. tty-----teletype3. ping----packet internet groper4. nohup-----no hangup5. su-------switch user6. df--------disk free7. cat...
分类:
其他好文 时间:
2014-10-03 18:06:44
阅读次数:
308
1、二层交换机配置1、VTP学生宿舍/教学Switch(config)#vtpdomainYeyuPeiSwitch(config)#vtpmodeclient2、接口划入vlan学生宿舍Switch(config)#interfacefastEthernet0/1Switch(config-if)#switchportmodeaccessSwitch(config-if)#switchportaccessvlan10Switch(config-if)spann..
分类:
其他好文 时间:
2014-10-03 15:41:25
阅读次数:
433