c++试验点
来源:互联网 发布:初级程序员考试资料 编辑:程序博客网 时间:2024/06/05 09:57
为了面试,不得不把有些东西整理一下
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////function.cpp
#include "incl.h"
#define TRUE 1
#define FALSE 0
int find_char(char **strings,int value)
{
assert(strings!=NULL);
while(*strings!=NULL)
{
while(**strings!=0)
if(*(*strings)++==value)
return TRUE;
strings++;
}
return FALSE;
}
////////////////////////////////////////////////////
void notConstRef(int &a)
{
a++;
}
void constRef(const int &a)
{
return;
}
///////////////////////////////////////////////////
//下面一个函数目的在于告诉你case语句的特别之处,如果你不用break语句。
void testCase()
{
using namespace std;
int a='/t';
int c=0;
int word=0;
int line=0;
switch(a)
{
case '/n':
line+=1;
case ' ':
case '/t':
word+=1;
default :
c+=1;
}
cout<<"c: "<<c<<endl;
cout<<"word: "<<word<<endl;
cout<<"line: "<<line<<endl;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////incl.h
int find_char(char **strings,int value);
void notConstRef(int &a);
void constRef(const int &a);
void testCase();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////主程序
#include <iostream>
#include "incl.h"
int main()
{
using namespace std;
//测试&变量别名的初始化和赋值的意义大不同
int one=3;
int next=4;
int &oneAlian=one;
cout<<one<<" "<<oneAlian<<endl;
cout<<&one<<" "<<&oneAlian<<endl;
oneAlian=next;
cout<<one<<" "<<oneAlian<<endl;
cout<<&one<<" "<<&oneAlian<<endl;
cout<<"**********"<<&next<<"****************"<<endl;
//测试字符串常量在表达式里面表示首地址的事实
printf("%c/n","0123456789ABCDEF"[3]);
printf("%s/n","0123456789ABCDEF"+3);
//说面下表操作就是指针加常数的事实
printf("%c/n",3["abcdefg"]);
cout<<"********************************************"<<endl;
testCase();
cout<<"*******************************"<<endl;
char *s[]={"abcde","fghijk",0};//此处如何声明为好?
int ifExist=find_char(s,'l');
cout<<ifExist<<endl;
cout<<"******************下面演示了能做引用实参时候可能的临时变量问题******************"<<endl;
int testIfConst=1;
notConstRef(testIfConst);
//notConstRef(testIfConst+1);
//notConstRef(2);
constRef(testIfConst+1);
constRef(2);
cout<<"testIfConst: "<<testIfConst;
}
- c++试验点
- C++50点
- C#--第三次试验
- hibernate入门试验的几点注意
- 试验:贝塞尔数组点的展开
- 试验
- 试验
- 试验
- 试验
- 试验
- 试验
- 试验
- 试验
- 试验
- 试验~~~~
- 试验
- 试验
- 试验
- 请慎用Ajax请求来探测不存在的资源
- 通过inf文件让Win XP实现自动维护 [可实现系统定时任务]
- 批处理文件bat 语法备忘
- 抽象工厂模式(Abstract Factory Pattern)
- 迟来的计划
- c++试验点
- 无风险与低风险投资理财渠道总结--转NB联盟阿鸡的文章
- 梦想归梦想,现实还是现实
- 通过点击Item的图标可以实现对可执行文件的调用
- 在一个衰减信道上利用多用户分集对服务质量的有效支持(翻译)
- 什么是AIX
- 数据库事件功能
- 用专用软件解决网络布线资料存档难题
- AJAX:开始