码迷,mamicode.com
首页 > 其他好文 > 详细

实验7

时间:2015-05-07 18:34:26      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:


#include<iostream>
#include<string>
using namespace std;
enum Rank{i3,i5,i7};
class CPU{
public:
    CPU(){}
//    CPU(int v,float f,Rank r) v1(v),f1(f),r1(r)
//    {cout<<"设置了对象"<<endl;}
int    Getv(){
        return v;
    }
float Getf(){
        return f;
   }
Rank  GetRank(){
        return r;
    }
void  Setv(int v){
      this->v=v;
}
void Setf(float f){
    this->f=f;
}
void Set(int r){
     this->r=(Rank)r;
}
private:
    int v;
    float f;
    Rank r;
};
int main(){
int v;
float f;
int r;
cin>>v>>f>>r;
CPU *cpu=new CPU[2];
 cpu[0].Setv(v);
 cpu[0].Setf(f);
 cpu[0].Set(r);
 cout<<cpu[0].Getv()<<"伏特\n"<<cpu[0].Getf()<<endl;
 switch (cpu[0].GetRank()){
    case i3:cout<<"i3"<<endl;break;
    case i5:cout<<"i5"<<endl;break;
    case i7:cout<<"i7"<<endl;break;
 }
 return 0;
}

 

 1 #include "stdafx.h"
 2 #include<iostream>
 3 #include<string>
 4 using namespace std;
 5 enum CPU_Rank{i3,i5,i7};
 6 CPU_Rank Rank;
 7 class CPU{
 8 public:
 9     CPU(){}
10 //    CPU(int v,float f,Rank r) v1(v),f1(f),r1(r)
11 //    {cout<<"设置了对象"<<endl;}
12 int    Getv(){
13         return v;
14     }
15 float Getf(){
16         return f;
17    }
18 Rank  GetRank(){
19         return r;
20     }
21 void  Setv(int v)
22       this->v=v;
23 }
24 void Setf(float f){
25     this->f=f;
26 }
27 void Set(int r){
28      this->r=r;
29 }
30 private:
31     int v;
32     float f;
33     Rank r;
34 };
35 int main(){
36 int v;
37 float f;
38 Rank r;
39 cin>>v>>f>>r;
40 CPU *cpu=new CPU[2];
41  cpu[0].Setv(v);
42  cpu[0].Setf(f);
43  cpu[0].Set(r);
44  cout<<cpu[0].Getv<<"伏特\n"<<cpu[0].Getf<<endl;
45  switch (cpu[0].GetRank()){
46     case i3:cout<<"i3"<<endl;break;
47     case i5:cout<<"i5"<<endl;break;
48     case i7:cout<<"i7"<<endl;break;
49  }
50  return 0;
51 }

 

实验7

标签:

原文地址:http://www.cnblogs.com/qianxunke/p/4485627.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!