C++这两道题调试不出来哪位大大给个结果?

来源:百度知道 编辑:UC知道 时间:2024/05/16 02:55:39
2
#include<iostream.h>
#include<stdlib.h>
class timer
{
int seconds;
public:
timer(){seconds=0;}
timer(int t)
{seconds=t;}
timer(int min,int sec)
{seconds=min*60+sec;}
gettime()
{return seconds;}
};
main()
timer a,b(10),c(1,10);
cout<<"seconds1="<<a.gettime()<<endl;
cout<<"seconds2="<<b.gettime()<<endl;
cout<<"seconds3="<<c.gettime()<<endl;
return 0;}

4
#include<iostream.h>
class base
{pubilc:
base(int x,int y){a=x;b=y}
void show() {cout<<"base:"<<a<<","<<endl;}
private:
int a,b;};
class derived(int x,int y,int z):base(x,y),c(z){}
void show() {cout<<"derived:"<<c<<endl;}
private:
int c;};
void main(){
base b(50,50),*pb;
d

2.
#include<iostream.h>
#include<stdlib.h>
class timer
{
int seconds;
public:
timer(){seconds=0;}
timer(int t)
{seconds=t;}
timer(int min,int sec)
{seconds=min*60+sec;}
int gettime() //修改部分
{return seconds;}
};
main()
{ //修改部分
timer a,b(10),c(1,10);
cout<<"seconds1="<<a.gettime()<<endl;
cout<<"seconds2="<<b.gettime()<<endl;
cout<<"seconds3="<<c.gettime()<<endl;
return 0;
}

4.
#include<iostream.h>
class base
{public:
base(int x,int y){a=x;b=y;}
void show() {cout<<"base:"<<a<<","<<endl;}
private:
int a,b;
};
class derived : base
{public:
derived(int x,int y,int z):base(x,y)
{c=z; }
void show() {cout<<"derived:"<