VC系列之------VC++8.0中自定义函数的使用

 

//写给正在学习VC++8.0的朋友们,或许没有什么帮助,但是这是在学习中所遇到的一些问题.

//代码在vs2005中运行通过.

#include "stdafx.h"
#include <IOstream>
#include <iomanip>
using namespace std;
int sample()
{
 int i;
 i=10;
 int j;
 j=15;
 return i*j;
}
int _tmain(int argc, _TCHAR* argv[])
{
    int num1=23;
    int num2=56;
 int c;
 cout<<"使用默认输出格式:"<<endl;
    cout<<num1<<num2;
 cout<<endl;
 cout<<"使用Setw输出格式:"<<endl;
 cout<<setw(6)<<num1<<setw(6)<<num2;
 cout<<endl;
 cout<<"使用函数时不注意细节从而得到两种不同的结果"<<endl;
 cout<<"cout<<sample得到的结果:"<<sample<<endl;  //错误的使用方法
 cout<<"cout<<sample()得到的结果:"<<sample()<<endl;//正确的使用方法
 cin>>c;
 return 0;
}

运行后的结果大家可以看一下有什么不同,体会一下.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值