一种构造组合方法以及bind的一种用法
2008-07-17 15:07
134 查看
#include <iostream>
#include <string>
#include <boost/bind.hpp>
#include <algorithm>
#include <functional>
#include <string>
#include <iterator>
class base
{
public:
virtual void report(void)
{
std::cout<<"this is base"<<std::endl;
}
virtual ~base()
{}
protected:
private:
};
class sub:public base
{
public:
virtual void report(void)
{
std::cout<<"this is sub"<<std::endl;
}
protected:
private:
};
void print(int value)
{
int mod = 0;
int count = 0;
do
{
mod = value % 10;
value = value / 10;
count++;
std::cout<<mod<<std::endl;
} while(value > 0);
std::cout<<count<<std::endl;
}
void get_next(int init_seq[],int n,int length)
{
int j = -1;
bool is_over = true;
int count = 0;
do
{
std::copy(init_seq,init_seq+n,std::ostream_iterator<int>(std::cout));
count++;
is_over = true;
j = -1;
std::cout<<std::endl;
//get max j
for(int i=0; i<n; i++)
{
if(init_seq[i] < length-n+1+i)
{
j = i;
}
}
if (j>=0 && j<=n-1)
{
is_over = false;
init_seq[j]++;
for(int k=j+1; k<n; k++)
{
init_seq[k] = init_seq[k-1]+1;
}
}
} while(!is_over);
//std::copy(init_seq,init_seq+n,std::ostream_iterator<int>(std::cout));
//count++;
std::cout<<count<<std::endl;
}
const int select_length = 7;
//1......9不包括0
const int all_length = 9;
int main(void)
{
boost::bind(&base::report,_1)(new base());
boost::bind(&base::report,_1)(new sub);
//print(123456);
int seq[select_length];
for(int i=0; i<select_length; i++)
{
seq[i] = i + 1;
}
get_next(seq,select_length,all_length);
}
#include <string>
#include <boost/bind.hpp>
#include <algorithm>
#include <functional>
#include <string>
#include <iterator>
class base
{
public:
virtual void report(void)
{
std::cout<<"this is base"<<std::endl;
}
virtual ~base()
{}
protected:
private:
};
class sub:public base
{
public:
virtual void report(void)
{
std::cout<<"this is sub"<<std::endl;
}
protected:
private:
};
void print(int value)
{
int mod = 0;
int count = 0;
do
{
mod = value % 10;
value = value / 10;
count++;
std::cout<<mod<<std::endl;
} while(value > 0);
std::cout<<count<<std::endl;
}
void get_next(int init_seq[],int n,int length)
{
int j = -1;
bool is_over = true;
int count = 0;
do
{
std::copy(init_seq,init_seq+n,std::ostream_iterator<int>(std::cout));
count++;
is_over = true;
j = -1;
std::cout<<std::endl;
//get max j
for(int i=0; i<n; i++)
{
if(init_seq[i] < length-n+1+i)
{
j = i;
}
}
if (j>=0 && j<=n-1)
{
is_over = false;
init_seq[j]++;
for(int k=j+1; k<n; k++)
{
init_seq[k] = init_seq[k-1]+1;
}
}
} while(!is_over);
//std::copy(init_seq,init_seq+n,std::ostream_iterator<int>(std::cout));
//count++;
std::cout<<count<<std::endl;
}
const int select_length = 7;
//1......9不包括0
const int all_length = 9;
int main(void)
{
boost::bind(&base::report,_1)(new base());
boost::bind(&base::report,_1)(new sub);
//print(123456);
int seq[select_length];
for(int i=0; i<select_length; i++)
{
seq[i] = i + 1;
}
get_next(seq,select_length,all_length);
}
相关文章推荐
- 求组合个数 POJ2249 以及一种组合的输出方法
- java中this用法 super()用法 以及构造方法
- ASP生成静态网页,学习CASE的用法,以及“权限”的一种控制方法
- 动态构造 Java 类的一种方法: javassist (1)
- for双层循环的一种使用方法:Java新用法
- java synchronized关键字的用法以及锁的等级:方法锁、对象锁、类锁
- Java静态初始化,实例初始化以及构造方法
- HashMap的一般用法以及遍历方法
- gml文件读写 hashmap用法与遍历 以及 文本文件解析方法
- UCI用法说明(一种读写文件的方法)
- Spring的两种依赖注入方式:setter方法注入与构造方法注入 以及两种方式的区别!
- Java静态初始化,非静态初始化以及构造方法
- java中equals方法的用法以及==的用法(转)
- java properties 的六种读取方法 以及一种自己最方便的实现
- TypeError: unhashable type: 'matrix'解决方法 以及 Python3下map函数的显示问题、 python numpy中nonzero()的用法
- Android AIDL bindService后不能调用onServiceConnected方法(一种情况)
- [图解教程]Eclipse不可不知的用法之一:自动生成Getter、Setter和构造方法
- 黑马程序员-OC的构造方法init以及自定义构造方法
- 【入门篇】Activiti三种网关的绘制方法以及简单的用法
- PHP学习:$_GET,$_POST,$_REQUEST和$_SERVER的一些用法,以及parse_str方法