ZEKEGU1997 2018-10-27 10:14 采纳率: 0%
浏览 1666

error C2143: 语法错误 : 缺少“;”(在“.”的前面)

错误在 cpu.run();
cpu.stop();
到底怎么改呢

 #include "stdafx.h"
#include<iostream>
using namespace std;

enum cpu_rank{P1=1,P2,P3,P4,P5,P6,P7};

class cpu
{
public:
    cpu(cpu_rank r1,int f1,float v1);
    void run(){cout<<"cpu is running"<<endl;}
    void stop(){cout<<"cpu is stopped"<<endl;}
private:
    cpu_rank rank;
    int freq;
    float volt;
};
cpu::cpu(cpu_rank r1,int f1,float v1)
{
    rank=r1;
    freq=f1;
    volt=v1;
}

int _tmain(int argc, _TCHAR* argv[])
{
    cpu c0(P1,133,5.8f);
    cpu.run();
    cpu.stop();
    return 0;
}
  • 写回答

1条回答 默认 最新

  • threenewbee 2018-10-27 10:41
    关注

    cpu.run();
    cpu.stop();
    ->
    c0.run();
    c0.stop();

    评论

报告相同问题?