C++函数的 对象参数
#include <iostream.h>class INT28
{
public:
INT28(unsigned x)
{
if(x>0xfffffff)
{
cout<<"error INT28 initializer! \n";
data=0;
}
data=x;
}
int getbitl(int i)
{
if(i<1 || i>28)
{
cout<<"\nerror i="<<i<<endl;
return -1;
}
int y=data>>(28-i);
return y%2;
}
void ls()
{
int x=getbitl(1);
data=data<<5;
data=data>>4;
data+=x;
}
void out()
{
for(int i=1;i<=28;i++)
{
cout<<getbitl(i);
if(i%4==0) cout<<endl;
}
cout<<"\n\n";
}
unsigned data; //32-4 bit
};
class INT56
{
public:
INT56(INT28 h, INT28 l)//??INT28????????
{
hi=h;lo=l;
}
int getbitl(int i)
{
if(i<1 || i>56)
{
cout<<"\nerror i="<<i<<endl;
return -1;
}
if(i<=28)
{
int y=hi.data>>(28-i);
return y%2;
}
else
{
int y=lo.data>>(56-i);
return y%2;
}
}
void out()
{
for(int i=1;i<=56;i++)
{
cout<<getbitl(i);
if(i%4==0) cout<<endl;
}
cout<<"\n\n";
}
INT28 hi, lo; //28+28 bit
};
void main()
{
}
以上程序编译后有如下出错信息,该如何解决?
--------------------Configuration: ex - Win32 Debug--------------------
Compiling...
ex.cpp
e:\i\ls\ex.cpp(55) : error C2512: 'INT28' : no appropriate default constructor available
e:\i\ls\ex.cpp(55) : error C2512: 'INT28' : no appropriate default constructor available
Error executing cl.exe.
ex.exe - 2 error(s), 0 warning(s)