练习21
2017-05-29 12:35
113 查看
#include <iostream>
using namespace std;
enum Core { Single, Dual, Quad };
enum Words { Bit32, Bit64 };
enum HyperThread { Support, NotSupport };
class CPU {
public:
CPU(unsigned frequence, Core type, Words length, HyperThread mode)
: frequence (frequence), CoreType (type), WordLen (length), mode(mode) { }
void show();
private:
unsigned frequence: 32;
Core CoreType: 3;
Words WordLen: 2;
HyperThread mode: 2;
};
void CPU::show() {
cout << " Frequence: " << frequence << endl;
cout << " Core: ";
switch ((unsigned)CoreType) {
case Single: cout << " Single-Core"; break;
case Dual:
cout << " Dual-Core"; break;
case Quad:
cout << " Quad-Core"; break;
}
cout << endl;
cout << " Words: ";
switch ((unsigned)WordLen) {
case Bit32:
cout << "32-bits len"; break;
case Bit64:
cout << "64-bits len"; break;
}
cout << endl;
cout << " HyperThread: ";
switch ((unsigned)mode) {
case Support:
cout << "Support Hyper-Thread"; break;
case NotSupport:
cout << "Not Support Hyper-Thread"; break;
}
cout << endl;
}
int main() {
CPU c(3000000000, Quad, Bit64,Support);
cout << "Size of Class CPU: " << sizeof(CPU) << endl;
c.show();
return 0;
}
using namespace std;
enum Core { Single, Dual, Quad };
enum Words { Bit32, Bit64 };
enum HyperThread { Support, NotSupport };
class CPU {
public:
CPU(unsigned frequence, Core type, Words length, HyperThread mode)
: frequence (frequence), CoreType (type), WordLen (length), mode(mode) { }
void show();
private:
unsigned frequence: 32;
Core CoreType: 3;
Words WordLen: 2;
HyperThread mode: 2;
};
void CPU::show() {
cout << " Frequence: " << frequence << endl;
cout << " Core: ";
switch ((unsigned)CoreType) {
case Single: cout << " Single-Core"; break;
case Dual:
cout << " Dual-Core"; break;
case Quad:
cout << " Quad-Core"; break;
}
cout << endl;
cout << " Words: ";
switch ((unsigned)WordLen) {
case Bit32:
cout << "32-bits len"; break;
case Bit64:
cout << "64-bits len"; break;
}
cout << endl;
cout << " HyperThread: ";
switch ((unsigned)mode) {
case Support:
cout << "Support Hyper-Thread"; break;
case NotSupport:
cout << "Not Support Hyper-Thread"; break;
}
cout << endl;
}
int main() {
CPU c(3000000000, Quad, Bit64,Support);
cout << "Size of Class CPU: " << sizeof(CPU) << endl;
c.show();
return 0;
}
相关文章推荐
- 笨办法学Python学习笔记 练习21
- 算法练习(21):Frog Jump
- 【SICP练习】21 练习1.27
- 练习,输出1/3-3/5+5/7-7/9…+19/21的结果
- 第7周 C语言程序设计(新2版) 练习1-21 空格串替换为最小数目的空格和制表符
- Python 练习 21
- 练习1-21 编写程序entab,将空格串替换成最少数量的制表符和空格,但要保持单词之间的间隔不变。假设制表符终止位的位置与练习1-20的detab程序的情况相同。当使用一个制表符或者一个空格都可以到达下一个制表符终止位时,选用哪种替换字符比较好。
- 算法练习-求21位数的水仙花数
- 动态规划练习--21(三角形最佳路径问题)
- 练习21
- 郭克华手机编程教学视频----我的练习源码(21)案例:快手
- 英语练习 21 She is beautiful
- java编程思想第4版第15章泛型擦除笔记及练习21
- the c programing language 练习1-21 将空格字符替换为最少数量的制表符和空格
- 动态规划练习21:三角形最佳路径问题
- 练习 21:文件系统:修改根目录,chroot
- C 练习实例21-30
- 【21】Python100例基础练习(5)
- 基本功练习_2_21之8转10进制
- 【备战蓝桥杯】【递归】【C语言】【BASIC-21基础练习 Sine之舞】