
c++
fxqcn
这个作者很懒,什么都没留下…
展开
-
C++的纯虚函数和抽象类
#includeclass A{ public : virtual float area()=0; //定义纯虚函数};class rectangle : public A{ public : rectangle(float x,float y) {原创 2011-07-09 15:08:36 · 414 阅读 · 0 评论 -
排序算法实现
//version 1.03#include#include#includeusing namespace std;void swap(int &a, int &b){ int temp = a; a = b; b =temp;}template T myMax(T a, T b){ return a >= b ? a : b;}//////////////原创 2014-07-21 20:38:26 · 543 阅读 · 0 评论 -
C++虚函数深入测试
前一段时间写的c++虚函数的测试小程序原创 2014-07-21 20:55:22 · 434 阅读 · 0 评论 -
hash_map 和 hash_mutilmap
class hash_map{private: typedef hashtable,_Key,_HashFcn, _Select1st >,_EqualKey,_Alloc> _Ht; _Ht _M_ht; //可见hashmap内部的是使用hashtable实现的public: typedef typename _Ht::key_typ原创 2014-07-30 23:29:58 · 1191 阅读 · 0 评论 -
c++11新性能测试3
#include#includeusing namespace std;using namespace std::placeholders;//函数int half(int x) {return x/2;}//仿函数struct third_t { int operator()(int x) {return x/3;}};//结构体struct MyValue {原创 2014-08-09 21:51:53 · 535 阅读 · 0 评论 -
c++11新性能测试2
#include #include #include using namespace std;struct C {int* data;};struct D {int a; int b;};int main(){ shared_ptr p1; shared_ptr p2(nullptr); shared_ptr p3(new int); shared_p原创 2014-08-09 19:36:37 · 599 阅读 · 0 评论 -
C++11新性能测试
// shared_ptr::operator*#include #include #include using namespace std;int main () { int a[] = {1,2,3,4,5}; int b[] = {2,3,4,5,6}; int c[] = {3,4,5,6,7}; vector> vv; vv.reserve(10);原创 2014-08-09 19:33:36 · 653 阅读 · 0 评论 -
c++11新性能测试4
#include#include#include using namespace std;vector> func(){ vector> vv; int a[] = {1,2,3,4,5}; int b[] = {6,2,3,4,5}; int c[] = {5,2,2,4,5}; vv.push_back(vector(a, a+5));原创 2014-08-10 13:00:00 · 746 阅读 · 0 评论