2.4 函数的声明与定义

函数可以先声明后定义,如下:

#include<iostream>
int show(int, int);//函数声明
int main(){
    int a = 1, b = 2, c;
    c = show(a, b);
    std::cout << c << std::endl;
}

//函数定义
int show(int a, int b){
    return a + b;
}

 

posted @ 2015-05-14 13:21  cppstudy  阅读(249)  评论(0编辑  收藏  举报