【C++ Primer Plus】Part1.从头开始

序言

快毕业但是很慌,用大头书把C++重新学一遍。

参考资料

C++ Primer Plus 第六版 中文版

预备知识

  • C++特点
    继承了C语音的高效、简洁、快速、可移植的传统;
    面向对象的编程(OOP, Object Oriented Programming);
    模板:提供了全新的编程方法——泛型编程。
  • C++的编程方式
    过程性语言、面向对象语言。
  • etc.

C++中的基本概念

// myfirst.cpp -- displays a message
#include <iostream>								//一个预处理器指令
int main()										//函数头
{												//函数体的开始
	using namespace std;						//使定义可见
	cout << "Come up and C++ me some time.";	//消息
	cout << endl;								//另起一行
	cout << "You won't regret it!" << endl;		//更多的输出
	return 0;									//终止main()函数
}												//函数体的结尾

1. C语言输入和输出

C++能使用printf()、scanf()和其他所有标准C输入和输出函数,只需要包含常规C语言的stdio.h文件。

2. 上述代码包含的元素

  • 注释,由前缀//标识
  • 预处理器编译指令#include
  • 函数头:int main()
  • 编译指令 using namespace
  • 函数体,由{和}括起
  • 使用C++的cout 显示消息的语句
  • 结束main()函数的return语句

3. main()函数

发布了13 篇原创文章 · 获赞 2 · 访问量 518

猜你喜欢

转载自blog.csdn.net/qq_41103187/article/details/104453450