![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
见证大牛成长之路
这个作者很懒,什么都没留下…
展开
-
串结构练习——字符串连接
#include #include #include using namespace std; int main() { string a, b; while (cin >> a >> b) { cout << a + b << endl; } return 0; }原创 2014-09-24 02:12:18 · 613 阅读 · 0 评论 -
作用域运算符
今天主要来说以下一个新的东西——作用域运算符。 例:原创 2014-10-07 23:38:31 · 981 阅读 · 0 评论 -
内置函数
C++提供了一种提高效率的方法,即在编译时将所调用函数的代买嵌入到主函数中。 例如:原创 2014-09-28 11:17:20 · 638 阅读 · 0 评论 -
C++变量的引用
有默认参数的函数 Float area(float r=6.5); Area()//相当于area(6.5); Area(7.5)//形参得到的值是7.5,而不是6.5。 这样做可以简化程序,提高运行效率。 例如:float volume(float h,float r=12.5); Volume (45.6) //程序相当于volume(45.6,12.5); Volume(34.原创 2014-09-27 15:44:45 · 676 阅读 · 0 评论 -
数据结构实验之二叉树的建立与遍历
#include #include #include #include using namespace std; struct node { char date; node *l, *r; }; node *build(node *p) { char x; cin >> x; if (x == ',') { p = NULL; } else { p = new(n原创 2014-09-24 17:38:48 · 913 阅读 · 0 评论 -
cin和cout的简单实用
从C到C++ 大二开始了,大一学的C,大二开始了C++的课程,首先C语言是结构化和模块化的语言,它是面向过程的,而C++是面向对象的,这就大大的加强了程序员对程序的可利用性和可操作性。 C++保留了C的缘由的所有优点,增加了面向对象的机制。由于C++对C的改进主要体现在增加了使用与面向对象程序设计的“类”;还有一个就是对C的扩充。 下面介绍少一个简单的小程序: #include usi原创 2014-09-26 13:26:54 · 2173 阅读 · 0 评论 -
C++第三讲
C++的const Const是用来定义常变量的,在C中我们学过define,比如 #define pi 3.14159的意思是把pi全部置换为3.14159.在预编译之后,程序中不会再有pi这个标识符。Pi不是变量,没有类型,不占用存储单元。而且容易出错。如: Int a=1,b=2; #define pi 3.14159 #define r a+b Cout 输出的结果不是3.1原创 2014-09-27 01:25:12 · 689 阅读 · 0 评论 -
使用类型转换函数的简单例子
#include #include using namespace std; class myclass { public: myclass() { real = 0; imag = 0; } myclass(double r, double i) { real = r; imag = i; } //类型转换函数 operator double() { r原创 2014-09-25 23:45:15 · 765 阅读 · 0 评论 -
重载“流提取运算符—— >> ”
#include #include using namespace std; class myclass { public: friend ostream&operator <<(ostream&, myclass&); friend istream&operator >>(istream&, myclass&); private: double real; double imag;原创 2014-09-26 00:26:56 · 2064 阅读 · 0 评论 -
string和vector
今天有必要在把以前血的string和vector这两种类型再详细的说一下!! 简单介绍一下几种初始化string对象的方式: String s1; //默认构造函数,s1为空串. String s2(s1); //将s2初始化为s1. String s3(“hello world”); //将s3初始化为一个字符串 String s4(n,’c’); //将s4初始化为n个’原创 2014-10-11 22:13:55 · 1591 阅读 · 0 评论