没有合适的资源?快使用搜索试试~ 我知道了~
关于C的学习方法论及资料下载和编码习惯和方法光货单号
资源推荐
资源详情
资源评论
C++笔记 2007-03-27
1、程序由函数组成,函数只完成自己特定的功能即可
把函数声明写在头文件里(想使用函数时,可直接导入头文件,调用函数),把函数实现写在".cc"文件中
把多个".cc"文件编译成可执行文件 ->分别编译成".o"文件,再连接到一起
2、值传递
函数中的参数传递是值传递,形参只是实参的一份拷贝数据,在函数中改变形参的值,对实参无影响
3、作业分析:显示层(与用户的交互)
操作数据(完成业务逻辑) biz层
数据(id , password , balance )
Bank实现代码
================================================================
biz.cc
================================================================
//operation
/* p : Password of account .
* b : balance of account .
* return : id of account .
*/
long create( int p , double b );
void save( double sum ) ;
/*
* return : 0 success , otherwise -1 returned .
*/
1、程序由函数组成,函数只完成自己特定的功能即可
把函数声明写在头文件里(想使用函数时,可直接导入头文件,调用函数),把函数实现写在".cc"文件中
把多个".cc"文件编译成可执行文件 ->分别编译成".o"文件,再连接到一起
2、值传递
函数中的参数传递是值传递,形参只是实参的一份拷贝数据,在函数中改变形参的值,对实参无影响
3、作业分析:显示层(与用户的交互)
操作数据(完成业务逻辑) biz层
数据(id , password , balance )
Bank实现代码
================================================================
biz.cc
================================================================
//operation
/* p : Password of account .
* b : balance of account .
* return : id of account .
*/
long create( int p , double b );
void save( double sum ) ;
/*
* return : 0 success , otherwise -1 returned .
*/
int withdraw( int p , double sum ) ;
double query( int p ) ;
long generateId();
================================================================
biz.cc
================================================================
static long id ;
static int passwd ;
static double balance ;
#include <iostream>
using namespace std;
long generateId(){
static int id = 1 ;
return id++ ;
}
long create( int p , double b ){
id = generateId();
passwd = p ;
balance = b ;
return id ;
}
void save( double sum ){
balance += sum ;
}
int withdraw( int p , double sum ){
if( p != passwd ){
cout<<"invalid password ." << endl;
return -1 ;
}
double query( int p ) ;
long generateId();
================================================================
biz.cc
================================================================
static long id ;
static int passwd ;
static double balance ;
#include <iostream>
using namespace std;
long generateId(){
static int id = 1 ;
return id++ ;
}
long create( int p , double b ){
id = generateId();
passwd = p ;
balance = b ;
return id ;
}
void save( double sum ){
balance += sum ;
}
int withdraw( int p , double sum ){
if( p != passwd ){
cout<<"invalid password ." << endl;
return -1 ;
}
剩余8页未读,继续阅读
资源评论
qj19871987
- 粉丝: 0
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功