三、改錯題(本大題共5小題,每小題2分,共10分)
下面的類定義中有一處錯誤,請用下橫線標出錯誤所在行并給出修改意見。
41.#include<iostream.h>
main(){
int x=9,y=8,z=7;
const int * p=z;
cout<< * p<<endl;
}
42.#include<iostream.h>
main(){
int x=8,y=6;
const int*const p=&x;
p=&y;
cout<<* p<<endl;
}
43.#include<iostream.h>
main(){
folat p;
p=new folat[5];
for(int i=0;i<5;i++)
{cin>> * (p+i);cout<< * (p+i)<<endl;}
delete p;
}
44.template<class T>
T f(T x){
T y;
y=x+T;
return y;
}
45.#include<iostream.h>
class point{
int x;
public:void init(int a){x=a;}
int getx(){return x;}
void setx(int a){x=a;}
};
main(){
point a;
a.init(20,30);
cout<<a.getx()<<endl;
}