C++ Primer Plus学习笔记:第二章

来源:互联网 发布:淘宝免费模板 编辑:程序博客网 时间:2024/05/01 19:24

2.6

1.到底什么是函数?

C++程序中的模块称之为函数。

2.#include<iostream>的作用是什么?

该编译指令导致预处理器将iostream文件中的内容添加到程序中去,在源代码被编译之前,替换或添加文本。

3.命名空间的作用是什么?

using namespace std;

定义名为std的空间,程序可以使用这个命名空间的定义,与其他命名空间进行区别,可以嵌套使用。

4.打印Hello word

cout<<"hello  word\n";或cout<<'hello word"<<endl;

5.  名为Cheese的整数变量:  int Cheeses;  

                                                     int  const Cheeses=37;

                                                    cin>>Cheeses;

6. int froop(double t);

    调用该函数时,参数传递的是double型,返回值是以个int 可以这样使用:int test1=froop(6.17);

void rattle(int n);

  调用该函数时,void型无返回值且参数为int,可以这样使用:rattle(89);

int prune(void);

调用该函数时(括弧中有void或为空,表示函数不接受任何的参数),可以这样使用:int test2=prune();

7. return 的用法

  函数为void型时,或隐式无不接受任何参数,则不使用return,反之,有返回值则使用。


0 0
原创粉丝点击