急需解疑!谢谢!!
#include <iostream>#include <string.h>
using namespace std;
class Mystring{
public:
Mystring(char str1[90]="string",char str2[90]="number"){
a=str1;
b=str2;
}
~Mystring(){
cout<<"Destructor called"<<endl;
}
string setstring(char str1[90],char str2[90]){
a=str1;
b=str2;
cout<<"input the string 1:"<<endl;
cin>>str1;
cout<<"input the string2 :"<<endl;
cin>>str2;
return a;
return b;
}
string showstring(char str1[90],char str2[90]){
gets(a);
gets(b);
if(strcmp(a,b)!=0)
if(strcmp(a,b)>0)
cout<<"the string 1 is greater than string 2:"<<a<<endl;
else
cout<<"the string 1 is less than string 2:"<<b<<endl;
else
cout<<"the string 1 is equal to string 2:"<<a<<endl;
return a;
return b;
}
private:
//char *str1,*str2;
char *a,*b;
};
string Mystring::setstring(char str1[90],char str2[90]);
string Mystring::showstring(char str1[90],char str2[90]);
void main(){
char *a,*b;
Mystring string();
string.setstring() ;
string.showstring() ;
string.~Mystring();
}
--------------------Configuration: wefwff - Win32 Debug--------------------
Compiling...
fw.cpp
C:\Program Files\VC++\MyProjects\wefwff\fw.cpp(54) : error C2228: left of '.setstring' must have class/struct/union type
C:\Program Files\VC++\MyProjects\wefwff\fw.cpp(55) : error C2228: left of '.showstring' must have class/struct/union type
执行 cl.exe 时出错.
fw.obj - 1 error(s), 0 warning(s)