c++解释--百度百科
-
c++
- 中文名
- C++语言
- 外文名
- The C++ Programming Language
- 类 别
- 计算机程序设计语言
- 创始人
- Bjarne Stroustrup
- 创始公司
- 贝尔实验室
- 基本内容
- 类、封装、重载、继承、模版
目录
从C到C++
名称由来
发展历史
与C的关系
与C不兼容之处
|
1
2
3
4
5
|
//从void*类型隐式转换为int*类型int*i=malloc(sizeof(int)*5); |
|
1
|
int*i=(int*)malloc(sizeof(int)*5); |
语言特点
优点
缺点
数据类型
数据定义
基本类型



类型转换
- 在混合类型的算术表达式中
- intival=3; doubledval=3.1415 ival+dval;//ival被提升为double类型:3.0
- 用另外一种类型的表达式赋值
- int*pi=NULL;//NULL(0)被转换成了int*类型的空指针值
- 用一个表达式传递给一个函数调用
- externdoublesqrt(double); sqrt(2);//2被提升为double类型:2.0
- 从一个函数返回一个表达式
- doubledifference(intival1,intival2) { returnival1-ival2;//返回值被提升为double类型. }
-
用法:static_cast < type-id > ( expression )说明:该运算符把expression转换为type-id类型,但没有运行时类型检查来保证转换的安全性。
-
用法:dynamic_cast < type-id > (expression)说明:该运算符把expression转换成type-id类型的对象。Type-id必须是类的指针、类的引用或者void*;
-
用法:const_cast<type_id> (expression)说明:该运算符用来修改类型的const或volatile属性。除了const 或volatile修饰之外, type_id和expression的类型是一样的。
-
用法:reinterpret_cast<type-id> (expression)说明:type-id 必须是一个指针、引用、算术类型、函数指针或者成员指针。它可以把一个指针转换成一个整数,也可以把一个整数转换成一个指针(先把一个指针转换成一个整数,在把该整数转换成原类型的指针,还可以得到原先的指针值)。
编程技巧
new和delete
inline
函数重载
参数传递
缺省参数
使用STL
使用模板
类和对象
声明类类型
|
1
2
3
4
5
6
7
|
struct Student//声明了一个名为Student的结构体类型 { int num; char name[20]; char sex; }; Student stud1,stud2;//定义了两个结构体变量stud1和stud2,它只包括数据,没有包括操作 |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Student//以class开头 { int num; char name[20]; char sex;//以上3行是数据成员 void display()//这是成员函数 { cout<<″num:″<<num<<endl; cout<<″name:″<<name<<endl; cout<<″sex:″<<sex<<endl; };//以上4行是函数中的操作语句 }; Student stud,stud1;//定义了两个对象stud和stud1 |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
class Student//以class开头 { private://声明私有成员 intnum; char name[20]; char sex; public://声明公共成员 void display() { cout<<″num:″<<num<<endl; cout<<″name:″<<name<<endl; cout<<″sex:″<<sex<<endl; } }; Student stud1,stud2;//定义了两个对象stud1和stud2 |
|
1
2
3
4
5
6
7
8
|
class 类名 { private: //私有的数据和成员函数; public: //公用的数据和成员函数; }; |
定义对象
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Student{//声明类类型 public://先声明公用部分 void display(){ cout<<″num:″<<num<<endl; cout<<″name:″<<name<<endl; cout<<″sex:″<<sex<<endl; } private://后声明私有部分 int num; char name[20]; char sex; }stud1,stud2;//定义了两个Student类的对象 |
|
1
2
3
4
5
6
7
|
class//无类名 { private://声明以下部分为私有的 //... public://声明以下部分为公用的 //... }stud1,stud2;//定义了两个无类名的类对象 |
类和结构体
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
structStudent{//用关键字struct来声明一个类类型 private://声明以下部分为私有的 int num;//以下3行为数据成员 char name[20]; char sex; public://声明以下部分为公用的 void display(){//成员函数 cout<<″num:″<<num<<endl; cout<<″name:″<<name<<endl; cout<<″sex:″<<sex<<endl; } }; Student stud1,stud2;//定义了两个Student类的对象 |
关键字
|
asm
|
do
|
if
|
return
|
typedef
|
|
auto
|
double
|
inline
|
short
|
typeid
|
|
bool
|
dynamic_cast
|
int
|
signed
|
typename
|
|
break
|
else
|
long
|
sizeof
|
union
|
|
case
|
enum
|
mutable
|
static
|
unsigned
|
|
catch
|
explicit
|
namespace
|
static_cast
|
using
|
|
char
|
export
|
new
|
struct
|
virtual
|
|
class
|
extern
|
operator
|
switch
|
void
|
|
const
|
false
|
private
|
template
|
volatile
|
|
const_cast
|
float
|
protected
|
this
|
wchar_t
|
|
continue
|
for
|
public
|
throw
|
while
|
|
default
|
friend
|
register
|
true
|
|
|
delete
|
goto
|
reinterpret_cast
|
try
|
编程开发
代码实现
| Unix: | C, cc, cxx, c |
| GNU C++: | C, cc, cxx, cpp, c++ |
| Digital Mars: | cpp, cxx |
| Borland: | C++ cpp |
| Watcom: | cpp |
| Microsoft Visual C++: | cpp, cxx, cc |
| Metrowerks CodeWarrior: | cpp, cp, cc, cxx, c++ |
命令行开发方式
集成开发环境(IDE)
多泛型设计
经典著作
入门书籍
进阶书籍
高阶书籍
常见错误
|
英文
|
参考译文
|
|---|---|
|
Ambiguous operators need parentheses
|
模棱两可的操作符需要括号
|
|
Ambiguous symbol ''xxx''
|
不明确的符号
|
|
Argument list syntax error
|
参数表语法错误
|
|
Array bounds missing
|
数组界限符丢失
|
|
Array size toolarge
|
数组尺寸太大
|
|
Bad character in paramenters
|
参数中有不适当的字符
|
|
Bad file name format in include directive
|
包含命令中文件名格式不正确
|
|
Bad ifdef directive synatax
|
编译预处理ifdef有语法错
|
|
Bad undef directive syntax
|
编译预处理undef有语法错
|
|
Bit field too large
|
位字段太长
|
|
Call of non-function
|
调用未定义的函数
|
|
Call to function with no prototype
|
调用函数时没有函数的说明
|
|
Cannot modify a const object
|
不允许修改常量对象
|
|
Case outside of switch
|
漏掉了case 语句
|
|
Case syntax error
|
Case 语法错误
|
|
Code has no effect
|
代码不可能被执行到
|
|
Compound statement missing{
|
分程序漏掉"{"
|
|
Conflicting type modifiers
|
互相冲突的类型说明符设置
|
|
Constant expression required
|
需要常量表达式
|
|
Constant out of range in comparison
|
在比较中常量超出范围
|
|
Conversion may lose significant digits
|
转换时会丢失数值的精度
|
|
Conversion of near pointer not allowed
|
不允许转换近指针
|
|
Could not find file ''xxx''
|
找不到XXX文件
|
|
Declaration missing ;
|
声明中缺少";"
|
|
Declaration syntax error
|
声明中出现语法错误
|
|
Default outside of switch
|
Default 出现在switch语句之外
|
|
Define directive needs an identifier
|
定义编译预处理需要标识符
|
|
Division by zero
|
用零作除数
|
|
Do statement must have while
|
Do-while语句中缺少while部分
|
|
Enum syntax error
|
枚举类型语法错误
|
|
Enumeration constant syntax error
|
枚举常数语法错误
|
|
Error directive :xxx
|
错误的编译预处理命令
|
|
Error writing output file
|
写输出文件错误
|
|
Expression syntax error
|
表达式语法错误
|
|
Extra parameter in call
|
调用时出现多余错误
|
|
File name too long
|
文件名太长
|
|
Function call missing
|
函数调用缺少右括号
|
|
Fuction definition out of place
|
函数定义位置错误
|
|
Fuction should return a value
|
函数必需返回一个值
|
|
Goto statement missing label
|
Goto语句没有标号
|
|
Hexadecimal or octal constant too large
|
16进制或8进制常数太大
|
|
Illegal character ''x''
|
非法字符x
|
|
Illegal initialization
|
非法的初始化
|
|
Illegal octal digit
|
非法的8进制数字
|
|
Illegal pointer subtraction
|
非法的指针相减
|
|
Illegal structure operation
|
非法的结构体操作
|
|
Illegal use of floating point
|
非法的浮点运算
|
|
Illegal use of pointer
|
指针使用非法
|
|
Improper use of a typedefsymbol
|
类型定义符号使用不恰当
|
|
In-line assembly not allowed
|
不允许使用行间汇编
|
|
Incompatible storage class
|
存储类别不相容
|
|
Incompatible type conversion
|
不相容的类型转换
|
|
Incorrect number format
|
错误的数据格式
|
|
Incorrect use of default
|
Default使用不当
|
|
Invalid indirection
|
无效的间接运算
|
|
Invalid pointer addition
|
指针相加无效
|
|
Irreducible expression tree
|
无法执行的表达式运算
|
|
Lvalue required
|
需要逻辑值0或非0值
|
|
Macro argument syntax error
|
宏参数语法错误
|
|
Macro expansion too long
|
宏的扩展以后太长
|
|
Mismatched number of parameters in definition
|
定义中参数个数不匹配
|
|
Misplaced break
|
此处不应出现break语句
|
|
Misplaced continue
|
此处不应出现continue语句
|
|
Misplaced decimal point
|
此处不应出现小数点
|
|
Misplaced elif directive
|
不应编译预处理elif
|
|
Misplaced else
|
此处不应出现else
|
|
Misplaced else directive
|
此处不应出现编译预处理else
|
|
Misplaced endif directive
|
此处不应出现编译预处理endif
|
|
Must be addressable
|
必须是可以编址的
|
|
Must take address of memory location
|
必须存储定位的地址
|
|
No declaration for function ''xxx''
|
没有函数xxx的说明
|
|
No stack
|
缺少堆栈
|
|
No type information/没有类型信息
|
缺少堆栈
|
|
Non-portable pointer assignment
|
不可移动的指针(地址常数)赋值
|
|
Non-portable pointer comparison
|
不可移动的指针(地址常数)比较
|
|
Non-portable pointer conversion
|
不可移动的指针(地址常数)转换
|
|
Not a valid expression format type
|
不合法的表达式格式
|
|
Not an allowed type
|
不允许使用的类型
|
|
Numeric constant too large
|
数值常太大
|
|
Out of memory
|
内存不够用
|
|
Parameter ''xxx'' is never used
|
能数xxx没有用到
|
|
Pointer required on left side of ->
|
符号->的左边必须是指针
|
|
Possible use of ''xxx'' before definition
|
在定义之前就使用了xxx(警告)
|
|
Possibly incorrect assignment
|
赋值可能不正确
|
|
Redeclaration of ''xxx''
|
重复定义了xxx
|
|
Redefinition of ''xxx'' is not identical
|
xxx的两次定义不一致
|
|
Register allocation failure
|
寄存器定址失败
|
|
Repeat count needs an lvalue
|
重复计数需要逻辑值
|
|
Size of structure or array not known
|
结构体或数给大小不确定
|
|
Statement missing ;
|
语句后缺少";"
|
|
Structure or union syntax error
|
结构体或联合体语法错误
|
|
Structure size too large
|
结构体尺寸太大
|
|
Sub scripting missing ]
|
下标缺少右方括号
|
|
Superfluous & with function or array
|
函数或数组中有多余的"&"
|
|
Suspicious pointer conversion
|
可疑的指针转换
|
|
Symbol limit exceeded
|
符号超限
|
|
Too few parameters in call
|
函数调用时的实参少于函数的参数不
|
|
Too many default cases
|
Default太多(switch语句中一个)
|
|
Too many error or warning messages
|
错误或警告信息太多[13]
|
|
英文
|
参考译文
|
|---|---|
|
Too many type in declaration
|
说明中类型太多
|
|
Too much auto memory in function
|
函数用到的局部存储太多
|
|
Too much global data defined in file
|
文件中全局数据太多
|
|
Two consecutive dots
|
两个连续的句点
|
|
Type mismatch in parameter xxx
|
参数xxx类型不匹配
|
|
Type mismatch in redeclaration of ''xxx''
|
xxx重定义的类型不匹配
|
|
Unable to create output file ''xxx''
|
无法建立输出文件xxx
|
|
Unable to open include file ''xxx''
|
无法打开被包含的文件xxx
|
|
Unable to open input file ''xxx''
|
无法打开输入文件xxx
|
|
Undefined label ''xxx''
|
没有定义的标号xxx
|
|
Undefined structure ''xxx''
|
没有定义的结构xxx
|
|
Undefined symbol ''xxx''
|
没有定义的符号xxx
|
|
Unexpected end of file in comment started on line xxx
|
从xxx行开始的注解尚未结束文件不能结束
|
|
Unexpected end of file in conditional started on line xxx
|
从xxx 开始的条件语句 尚未结束文件不能结束
|
|
Unknown assemble instruction
|
未知的汇编结构
|
|
Unknown option
|
未知的操作
|
|
Unknown preprocessor directive: ''xxx''
|
不认识的预处理命令xxx
|
|
Unreachable code
|
无路可达的代码
|
|
Unterminated string or character constant
|
字符串缺少引号
|
|
User break
|
用户强行中断了程序
|
|
Void functions may not return a value
|
Void类型的函数不应有返回值
|
|
Wrong number of arguments
|
调用函数的参数数目错
|
|
''xxx'' not an argument
|
xxx不是参数
|
|
''xxx'' not part of structure
|
xxx不是结构体的一部分
|
|
xxx statement missing (
|
xxx语句缺少左括号
|
|
xxx statement missing )
|
xxx语句缺少右括号
|
|
xxx statement missing ;
|
xxx缺少分号
|
|
xxx'' declared but never used
|
说明了xxx但没有使用
|
|
xxx'' is assigned a value which is never used
|
给xxx赋了值但未用过
|
|
Zero length structure
|
结构体的长度为零[14]
|
争议
C++ 标准
C++ 98 标准
C++ 03 标准
C++ 11 标准
C++ 14 标准
c++解释--百度百科的更多相关文章
- MySQL解释--百度百科
MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下公司.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好的 RDBMS ...
- C#运用实例.读取csv里面的词条,对每一个词条抓取百度百科相关资料,然后存取到数据库
第一步:首先需要将csv先装换成datatable,这样我们就容易进行对datatable进行遍历: /// 将CSV文件的数据读取到DataTable中 /// CSV文件路径 /// 返回读取了C ...
- 爬虫实战(一) 用Python爬取百度百科
最近博主遇到这样一个需求:当用户输入一个词语时,返回这个词语的解释 我的第一个想法是做一个数据库,把常用的词语和词语的解释放到数据库里面,当用户查询时直接读取数据库结果 但是自己又没有心思做这样一个数 ...
- [转帖] 百度百科 sino
sino https://baike.baidu.com/item/sino/2830?fr=aladdin 百度百科 sinograin 中储粮 (组合词前缀) 编辑 讨论 Sino,就是「中国.东 ...
- java 如何爬取百度百科词条内容(java如何使用webmagic爬取百度词条)
这是老师所布置的作业 说一下我这里的爬去并非能把百度词条上的内容一字不漏的取下来(而是它分享链接的一个主要内容概括...)(他的主要内容我爬不到 也不想去研究大家有好办法可以call me) 例如 互 ...
- python爬虫—爬取百度百科数据
爬虫框架:开发平台 centos6.7 根据慕课网爬虫教程编写代码 片区百度百科url,标题,内容 分为4个模块:html_downloader.py 下载器 html_outputer.py 爬取数 ...
- [Python爬虫] Selenium获取百度百科旅游景点的InfoBox消息盒
前面我讲述过如何通过BeautifulSoup获取维基百科的消息盒,同样可以通过Spider获取网站内容,最近学习了Selenium+Phantomjs后,准备利用它们获取百度百科的旅游景点消息盒(I ...
- Python3爬取百度百科(配合PHP)
用PHP写了一个网页,可以获取百度百科词条.源代码已分享至github:https://github.com/1049451037/xiaobaike/tree/master 那么通过Python来爬 ...
- redis百度百科和维基百科知识总结:
1. 百度百科知识总结: Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value数据库,并提供多种语言的API.从2010年3月15日起,Redis ...
随机推荐
- Idea设置全白色 背景
IDEA设置全白色背景 标签(空格分隔): 工具使用 编辑框白色设置 菜单栏白色设置
- Eclipse SVN还原文件到历史版本详解
由于某些特殊原因,我们可能需要将SVN资源库中的某个文件回滚到以前的某个历史版本(准确地说,这不是"回滚","回滚"操作会导致指定版本到当前版本的变更记录丢失, ...
- [libgdx游戏开发教程]使用Libgdx进行游戏开发(8)-粒子系统
没有美工的程序员,能够依赖的还有粒子系统. 这一章我们将使用libGDX的粒子系统线性插值以及其他的方法来增加一些特效. 你也可以使用自己编辑的粒子效果,比如这个粒子文件dust:http://fil ...
- (2)Python 变量和运算符
一.python变量特点 python是弱类型语言,无需声明变量可以直接使用并且变量的数据类型可以动态改变 二.变量命名规则 1.不能使用python关键字 2.不能数字开头 3.不能包含空格 4.不 ...
- 大数据技术之_16_Scala学习_06_面向对象编程-高级+隐式转换和隐式值
第八章 面向对象编程-高级8.1 静态属性和静态方法8.1.1 静态属性-提出问题8.1.2 基本介绍8.1.3 伴生对象的快速入门8.1.4 伴生对象的小结8.1.5 最佳实践-使用伴生对象解决小孩 ...
- NOIP2018提高组模拟题(四)
能量(energy) Description 有一块能量田,它的形状是 n*m的矩形,每一个格子上都有一个能量值 a[x][y] (可正可负).一块矩形田的能量定义为它的每个格子的能量值之和. ...
- 树状数组优化DP 【模拟赛】删区间
哇,难受得一匹. 看到题的一瞬间竟然只想到了\(n^3\)的区间\(DP\) 一.\(40pts\) 设\(f[i][j]\)代表删去\(i\)到\(j\)这一段区间的最小代价和. 然后直接写普通的区 ...
- 差分+树状数组 线段树【P2357】 守墓人
题目描述-->p2357 守墓人 敲了一遍线段树,水过. 树状数组分析 主要思路: 差分 简单介绍一下差分(详细概念太麻烦,看下面. 给定一个数组 7 8 6 5 1 8 18 20 35 // ...
- 谜题15:令人晕头转向的Hello
下面的程序是对一个老生常谈的例子做出了稍许的变化之后的版本.那么,它会打印出什么呢? /** * Generated by the IBM IDL-to-Java compiler, version ...
- Android中的动态字符串的处理
1.效果显示 2. MainAcitivity.java package com.example.app2; import android.support.v7.app.AppCompatActivi ...
