摘要: from http://www.learncpp.com/cpp-tutorial/19-header-files/在程序中,.cpp扩展的文件并不是唯一一种常见的文件。另一种文件称为头文件,有时被称为include file。都文件基本都有一个.h扩展名。头文件的目的是将其它文件要用到的声明整合到一起。标准库头文件的使用看一下下面的程序: 1: #include <iostream> 2: int main() 3: { 4: using namespace std; 5: cout << "Hello, world!" << endl 阅读全文
posted @ 2012-04-17 16:38 grassofsky 阅读(369) 评论(0) 推荐(1) 编辑
摘要: from http://www.learncpp.com/cpp-tutorial/18-programs-with-multiple-files/当程序变得越来越大的时候,为了更好的组织,通常将它分为多个文件。使用IDE工作的一个优势在于利用它进行多文件项目的实施是很简单的。你已经知道了如何创建编译单文件项目。把新的文件加入到已经存在的项目中是很简单的。在Visual Studio 2005 Express,在解决方案的资源管理器中右键"source files",选择添加新的项目。给出新文件的名称,然后它将会添加到你的项目中。在Code::Blocks中也用类似的方式进 阅读全文
posted @ 2012-04-17 15:20 grassofsky 阅读(239) 评论(0) 推荐(0) 编辑
摘要: from http://www.learncpp.com/cpp-tutorial/17-forward-declarations/看一下下面这个表面上正确的add.cpp程序 1: #include <iostream> 2: 3: int main() 4: { 5: using namespace std; 6: cout << "The sum of 3 and 4 is: " << add(3, 4) << endl; 7: return 0; 8: } 9: 10: int add(int x, int y) .. 阅读全文
posted @ 2012-04-17 14:28 grassofsky 阅读(396) 评论(0) 推荐(1) 编辑
摘要: from http://www.learncpp.com/cpp-tutorial/16-whitespace-and-basic-formatting/空白符是被用于格式化的字符。在C++中,空白符主要有空格,制表符,换行。在C++编译器中往往使用一些小的处理将空白符忽略。因此,下面这些语句都是一样的: 1: cout << "Hello world!"; 2: 3: cout << "Hello world!"; 4: 5: cout << "Hello world!"; 6: ... 阅读全文
posted @ 2012-04-17 08:43 grassofsky 阅读(365) 评论(0) 推荐(0) 编辑