02 2011 档案

红黑树C++实现
摘要:参考CLRS第二版(ch 13)#ifndef _C_RB_TREE_H_#define _C_RB_TREE_H_#define NULL 0template <class KeyT, class DataT>class RB_TREE{public: RB_TREE():root(NULL){} void Insert(KeyT key, DataT data = NULL) { rb_nodes *node, *tmp; node = root; tmp = NULL; while(node != NULL) { tmp = node; if(key<node-> 阅读全文

posted @ 2011-02-23 21:29 ltang 阅读(423) 评论(0) 推荐(0)

(转帖)关于访问同类引用参数的私有变量的疑问
摘要:#include <iostream>using namespace std;class T {public: T(){a = 11;} int Get() const{return a;}private: int a;};class Test{public: Test(int a):m_a(a){} Test(const Test &t){m_a = t.m_a;} //拷贝构造函数,通过同类型的引用参数访问私有变量 Test& operator=(const Test &t) //赋值操作函数,通过同类型的引用参数访问私有变量 { m_a = t.m_a 阅读全文

posted @ 2011-02-22 16:05 ltang 阅读(486) 评论(0) 推荐(0)

导航