摘要: 还需要注意: 1.常对象或常引用或常指针只能调用常成员函数。但是普通对象(无const修饰)都能调用, 即:既能调用常成员函数,也能调用非常的。 2.常成员函数只能调用常成员函数,不能调用非常函数。 阅读全文
posted @ 2018-09-17 11:42 Jary霸 阅读(331) 评论(0) 推荐(0)
摘要: #include using namespace std; class Array { public: friend class A; // 好了,这时候类A可以使用Array里面的任何函数和变量了! Array(int age); void eat(); private: int age; }; Array::Array(int age) { ... 阅读全文
posted @ 2018-09-17 09:41 Jary霸 阅读(91) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2018-07-30 17:05 Jary霸 阅读(118) 评论(0) 推荐(0)
摘要: 参见:Graph 阅读全文
posted @ 2018-07-18 19:26 Jary霸 阅读(70) 评论(0) 推荐(0)
摘要: #include #include #include #include using namespace std; int main(void) { vector vec; // 这是个定义了一个向量,里面可以依次存储一个个的元素,相当于一个数组,还可以使用这个向量已经有了的函数,注意需要引入:#include vec.push_back(11); // 往里面存... 阅读全文
posted @ 2018-07-18 11:37 Jary霸 阅读(137) 评论(0) 推荐(0)
摘要: 项目: 线性表:参见LinerList,LinerList2 栈: 参见Stack 队列: 参见Queue 树: 参见Tree和Tree2 阅读全文
posted @ 2018-07-09 10:06 Jary霸 阅读(76) 评论(0) 推荐(0)
摘要: 这里也可以用 class T代替 typename T, class T比typename T要大一点,typename是对基础类型说的 阅读全文
posted @ 2018-07-06 16:35 Jary霸 阅读(103) 评论(0) 推荐(0)
摘要: 注意: 1. 模板本身是不会产生任何代码的,有了模板函数才会有对应的代码。 2. 也可以把template写成class,二者等价。 3. 使用模板函数的时候不能分开定义,全部写到.h文件中,不要.cpp文件了。 阅读全文
posted @ 2018-07-06 14:52 Jary霸 阅读(107) 评论(0) 推荐(0)
摘要: 可以通过成员函数或者友元函数来实现 参见项目:Operator 阅读全文
posted @ 2018-07-06 09:41 Jary霸 阅读(95) 评论(0) 推荐(0)
摘要: 1. static修饰的变量随变量的加载而加载,比对象要早。 2. 静态成员函数只能用静态的东西,非静态成员函数都能用(静态+非静态) 3. 可以使用对象调用静态的东西,可以使用类直接调用静态的东西,如:A::get(); 阅读全文
posted @ 2018-07-05 20:26 Jary霸 阅读(111) 评论(0) 推荐(0)