C++这个词在中国大陆的程序员圈子中通常被读做“C加加”,而西方的程序员通常读做“C plus plus”,“CPP”。 它是一种使用非常广泛的计算机编程语言。C++是一种静态数据类型检查的、支持多重编程范式的通用程序设计语言。它支持过程化程序设计、数据抽象、面向对象程序设计、泛型程序设计等多种程序设计风格。
在C的基础上,一九八三年又由贝尔实验室的Bjarne Strou-strup推出了C++。 C++进一步扩充和完善了C语言,成为一种面向 对象的程序设计语言。C++提出了一些更为深入的概念,它所支持的这些面向对象的概念容易将问题空间直接地映射到程序空间,为程序员提供了一种与传统结构程序设计不同的思维方式和编程方法。因而也增加了整个语言的复杂性,掌握起来有一定难度。
最初这种语言被称作“C with Classes”带类的C)。开始,C++是作为C语言的增强版出现的,从给C语言增加类开始,不断的增加新特性。虚函数(virtual function)、运算符重载(operator overloading)、多重继承(multiple inheritance)、模板(template)、异常(exception)、RTTI、命名空间(name space)逐渐被加入标准。
1998年国际标准组织(international standard organization, ISO)颁布了C++程序设计语言的国际标准ISO/IEC 1988-1998。C++是具有国际标准的编程语言,通常称作ANSI/ISOC++。
经典书籍《C++ Primer》
/**************************************************************************/
IDE:code::Blocks
#include <iostream>
using namespace std;
/*Function*/
int addNumbers(int x, int y)
{
int sum = 0;
sum = x + y;
return sum;
}
/*Class*/
class iSwordClass
{
private:
string name;
string sex;
string telphone;
string qq;
string address;
public:
iSwordClass()
{
cout << "This is the constructor of iSwordClass. This will be created automatically....\n";
}
void setName(string _name)
{
name = _name;
}
string getName()
{
return name;
}
void setSex(string _sex)
{
sex = _sex;
}
string getSex()
{
return sex;
}
void coolSaying()
{
cout << "Cool iSword!\n";
}
};
int main()
{
//cout << addNumbers(100,200)<<endl;
int x;
int y;
cout << "Please input x:";
cin >> x;
cout << "Please input y:";
cin >> y;
cout << "The sum of x and y is : ";
cout << addNumbers(x,y)<<endl;
cout << "Begin to new a object of iSwordClass....\n";
iSwordClass isObject; // new a object
cout << "/*********Use the class function coolSaying...***********************/\n";
isObject.coolSaying();
cout << "/*********Use the class function setters, and getters... ************/\n";
isObject.setName("Jack");
isObject.setSex("Male");
cout << isObject.getName()<< endl;
cout << isObject.getSex()<<endl;
return 0;
}