标签:表达 amp 简单 blog 题目 color 目的 github bsp
#include<iostream> #include<stdlib.h> using namespace std; class Random{ public: virtual void random(int quantity); }; class RandomNumber:public Random { int number; public: void random(int quantity){ number=rand()%11; } }; class RandomOperation:public Random { char operation; public: void random(int quantity){ int a=rand()%4; switch(a){ case 0:operation=‘+‘;break; case 1:operation=‘-‘;break; case 2:operation=‘*‘;break; case 3:operation=‘/‘; } } }; class SimpleFactory { public: static Random *creat_random(string &choose) { if("num"==choose) { return new RandomNumber(); } if("ope"==choose) { return new RandomOperation(); } } };
标签:表达 amp 简单 blog 题目 color 目的 github bsp
原文地址:http://www.cnblogs.com/qvq-qvq/p/6973863.html