
#include<iostream>
using namespace std;
enum Wordsize {thirty_two,sixty_four};
enum He {Single,Double,Four};
class cpu{
public:
cpu(unsigned hz,Wordsize wordsize,He he,bool ht):hz(hz),wordsize(wordsize),he(he),ht(ht){};
void show();
private:
unsigned hz :13;
Wordsize wordsize :1;
He he :2;
bool ht :1;
};
void cpu::show(){
cout<<"這臺電腦的主頻是:"<<hz<<endl;
switch(wordsize){
case thirty_two:cout<<"這臺電腦的字長是:"<<"32字"<<endl;
break;
case sixty_four:cout<<"這臺電腦的字長是:"<<"64字"<<endl;
break;
}
switch(he){
case Single:cout<<"這臺電腦的核數是:"<<"單核"<<endl;
break;
case Double:cout<<"這臺電腦的核數是:"<<"雙核"<<endl;
break;
case Four:cout<<"這臺電腦的核數是:"<<"四核"<<endl;
break;
}
cout<<(ht?"支持多執行緒":"不支持多執行緒")<<endl;
}
int main(){
cpu a(3000,sixty_four,Four,true);
a.show();
cout<<sizeof(cpu);
return 0;
}
uj5u.com熱心網友回復:
不應該是13+1+2+1等于17位 三個位元組嗎轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/188362.html
標籤:C語言
上一篇:運算式輸入
