急!急!!!求Visual c++高手帮住下 看看下面的题目

来源:百度知道 编辑:UC知道 时间:2024/06/18 01:47:15
都是只改*****found******下一行有错
(3)要求输出结果为
00:00:00
00:01:00

#include<iostream>
#include<iomanip>
using namespace std;

class StopWatch // "秒表"类
{
int hours; // 小时
int minutes; // 分钟
int seconds; // 秒
public:
StopWatch():hours(0), minutes (0), seconds(0){}
void reset(){hours=minutes=seconds=0;}
StopWatch operator++(int) // 后置++
{
StopWatch old=*this;
++(*this);
return old;
}
//前进1秒
StopWatch& operator++() // 前置++
{
// ERROR *********found*********
if(seconds++==60)
{
seconds=0; minutes++;
if(minutes==60)
{
minutes=0;
hours++;
}
}
// ERROR *********found*********
return this;
}
friend void show(StopWatch);
};

void show(StopWatch watch)

// ERROR *********found*********
if(seconds++==60)

if(++seconds==60) //左右自增的问题

// ERROR *********found*********
return this;

return *this;

(2)

#include <iostream>
using namespace std;

// 集合类的操作接口
class Collection
{
public:
// 向集合中添加一个元素
virtual void add(int e) = 0;

// 获取指定位置的元素
virtual int get(unsigned int i) const = 0;
};

// 实现了集合接口
class Array : public Collection
{
public:
Array(unsigned int s)
{
//**********found**********
a = new int[s];
size = s;
num = 0;
}

~Array()
{
//**********found**********
delete a;
}

virtual void add(int e)
{
if (num < size)
{
//**********found**********
a[num] = e;
num++