
C/C++
文章平均质量分 63
Roope_Ho
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C/C++:C++运算符重载
C++运算符重载:原创 2014-11-06 20:51:42 · 742 阅读 · 0 评论 -
C/C++:命名空间
这一原创 2014-11-04 11:07:26 · 560 阅读 · 0 评论 -
C/C++:C++面向对象
今天,学习的是用C++来面向对象。这里原创 2014-11-04 10:50:15 · 729 阅读 · 0 评论 -
C/C++ : 结构体
#includeusing namespace std;struct point{ int edg; char name[10];};int main(){ point a; cin >> a.edg >> a.name; point b = a; cin >> a.edg; cout << a.edg << " " << a.name <<" " << b.edg原创 2014-11-03 21:22:35 · 426 阅读 · 0 评论 -
C/C++:typedef关键字
#includetypedef struct{ int edg;}people;void say_hello(){ printf("hello word !\n");}typedef void (*fun) (); //指向无输入参数和返回类型的函数;int main(){ people p; p.edg = 18; printf("e原创 2014-11-03 22:11:57 · 490 阅读 · 0 评论 -
C/C++:函数指针
#include#include#includeusing namespace std;void say_hello(){ cout << "hello word !" << endl;}int main(){// say_hello(); 常用的普通方法; void(* p)(); // p就是函数指针; p = say_hello; // 令p指向say_hell原创 2014-11-03 21:27:28 · 561 阅读 · 0 评论 -
C/C++:结构体指针
#include#include#includeusing namespace std;struct point{ int edg; char *name;};/*int main(){ point p1; p1.edg = 32; point p2 = p1; p1.edg = 40; cout << p1.edg << " " << p2.edg << end原创 2014-11-03 21:25:45 · 624 阅读 · 0 评论 -
C/C++:C++构造方法和析构方法
这里是菜鸟C++构造方法原创 2014-11-04 16:57:36 · 1412 阅读 · 0 评论 -
C/C++:C++执行父类的方法
C++执行父类的方法首先,我们jianl8原创 2014-11-06 16:47:04 · 5603 阅读 · 0 评论 -
C++:联合类型(union)
联合类型(union):允许不同的数据类型访问相同的的,因为实际上他们就是在内存中相同的位置,声明和结构体差不多。和结构体的区别是结构体中的数据元素之间有相互联系,而联合中的数据元素是没有必然的联系的,是相互独立的。用了其中一个元素,另外的也就不能使用了。否则运行时会出错误。#includeusing namespace std;union student原创 2015-01-13 16:14:47 · 3602 阅读 · 1 评论 -
C++:枚举类型
#includeenum Direction{ UP,DOWN,LEFT,RIGHT};int main(int argc, char const *argv[]){ int a = 0; if(a==UP) { std::cout << "UP"; } return 0;}值得一提的是= =我在std::cout原创 2015-01-13 16:00:19 · 492 阅读 · 0 评论 -
C/C++:C++类的继承
一步一步往上爬:类的继承。首先建立fulei原创 2014-11-04 13:35:13 · 1011 阅读 · 0 评论 -
C/C++:C++执行父类的构造方法
C++执行父类的构造方法。这是在原来原创 2014-11-06 16:06:23 · 1523 阅读 · 0 评论 -
C/C++ :C++实函数、虚函数、纯虚函数、函数重写
C++实函数、虚函数、纯虚函数、函数重写和以前一样,先做好准备g原创 2014-11-06 18:21:43 · 2924 阅读 · 0 评论 -
C/C++:C++函数重载
C++函数重载首先,我们在原创 2014-11-06 18:46:14 · 685 阅读 · 0 评论 -
C/C++:C++伪函数
C++伪函数:所谓的伪函数,就是说它不是一个真正的函数,而是一个类或者说是一个结构体。#include void say_hello(){ std::cout << "hello world !" << std::endl;}class Hello{public: void operator () (){ std::c原创 2014-11-07 14:16:22 · 2395 阅读 · 3 评论 -
C/C++:C++引用
C++引用:首先,先写一个这样的程序:#include class point{private: int x, y;public: point(int x, int y){ this->x = x; this->y = y; }; int getX(){ return x;原创 2014-11-09 13:31:50 · 718 阅读 · 0 评论 -
C/C++:C++友元类
C++友元类:正常情况下,一个类是访问不到另一个类的私有成员的。就像下面这个:#include class A{private: int a;public: A(){ a = 1; }};class B:public A{public: B(){ std::cout << a <<原创 2014-11-09 15:33:22 · 945 阅读 · 0 评论 -
C/C++:string和stringstream的小例子
C++字符串常用操作1、string的可以用相加来连接两个字符串。#include#includeusing namespace std;int main(){ string str; str += "hello "; str += "world !"; cout << str << endl; return 0;}原创 2014-11-09 16:42:31 · 846 阅读 · 0 评论 -
C/C++:C++函数指针
C++函数指针:我先来写一个类object,规定函数指针指向的必须是object的成员,或其子类的成员。class object{ public: void (object::*p)();};好,然后我们再来写一个类hello继承于类object。写一个构造方法,用函数指针来指向输出object类型的。#include原创 2014-11-07 16:00:29 · 819 阅读 · 0 评论 -
遍历二叉树的各种操作(递归与非递归遍历)
先使用先序的方法建立一棵二叉树,然后分别使用递归与非递归的方法实现前序、中序、后序遍历二叉树,并使用了两种方法来进行层次遍历二叉树,一种方法就是使用STL中的queue,另外一种方法就是定义了一个数组队列,分别使用了front和rear两个数组的下标来表示入队与出队,还有两个操作就是求二叉树的深度、结点数。。。[cpp] view plaincopy转载 2014-11-14 15:24:01 · 967 阅读 · 0 评论 -
二叉树的建立和基本操作
树形结构要多利用递归来求解,递归的关键就是想清楚所有的基准情形,然后扩展到一般情况,写代码的时候最好把基准情况放在前面,把一般情况放在后面!定义二叉树结构体:[cpp] view plaincopytypedef struct BinaryTreeNode { TelemType data; stru转载 2014-11-14 15:53:25 · 17304 阅读 · 2 评论 -
c++头文件iomanip.h中的setw、setprecision、setfill和setbase函数
#include //不要用iostream.h ,会出现好多问题#include // io 流控制头文件, 主要是一些操纵用法如setw(int n),setprecision(int n) ,setbase(int n),setfill(char c)的. ▲setw(n)用法: 通俗地讲就是预设宽度 如 cout转载 2014-11-27 08:20:35 · 8632 阅读 · 0 评论 -
C/C++:迭代器的简单二分查找
I just don't want to regret it !#include #include #include #include using namespace std;int main(){ vectorc{1, 2, 3, 4, 5};//默认排好了序 auto beg = c.begin();auto end = c.end();//搜索原创 2015-04-07 21:03:24 · 1497 阅读 · 0 评论