C++入门经典-例4.1-声明、定义和使用函数

1:代码如下:

// 4.1.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
using namespace std;
void ShowMessage();    //函数声明语句
void ShowAge();        //函数声明语句
void ShowIndex();        //函数声明语句
void main()
{
    ShowMessage();    //函数调用语句
    ShowAge();        //函数调用语句
    ShowIndex();        //函数调用语句
}
void ShowMessage()
{
    cout << "HelloWorld!" << endl;
}
void ShowAge()
{
    int iAge=23;
    cout << "age is :" << iAge << endl;
}
void ShowIndex()
{
    int iIndex=10;
    cout << "Index is :" << iIndex << endl;
}
View Code

运行结果:

posted @ 2017-09-14 09:31  一串字符串  阅读(166)  评论(0编辑  收藏  举报