error C2440: '=' : cannot convert from 'char *' to 'char'
#include<iostream>usingnamespacestd;intmin(inta,intb);floatmin(floata,floatb);char*mi...
#include<iostream>
using namespace std;
int min(int a, int b);
float min(float a, float b);
char * min (char * a, char * b);
void main()
{
int min(int a, int b);
float min(float a, float b);
char * min (char * a, char * b);
int i1,i2,i;
cin>>i1>>i2;
i=min(i1,i2);
cout<<"i_min="<<i<<endl;
float f1,f2,f;
cin>>f1>>f2;
f=min(f1,f2);
cout<<"f_min="<<f<<endl;
char c1[200],c2[200],c;
cin>>c1>>c2;
c=min(c1,c2);
cout<<"c_min="<<c<<endl;
}
int min(int a, int b)
{
if(a>b) a=b;
return a;
}
float min(float a, float b)
{
if(a>b) a=b;
return a;
}
char * min (char * a, char * b)
{
if(strcmp(a,b)>0) a=b;
return a;
}
cpp(21) : error C2440: '=' : cannot convert from 'char *' to 'char'
There is no context in which this conversion is possible
帮忙看看如何改正,我是初学者
上面的问题我把 char c改为char *c就解决了,但函数重载方面就是无法做好,请高人指点 展开
using namespace std;
int min(int a, int b);
float min(float a, float b);
char * min (char * a, char * b);
void main()
{
int min(int a, int b);
float min(float a, float b);
char * min (char * a, char * b);
int i1,i2,i;
cin>>i1>>i2;
i=min(i1,i2);
cout<<"i_min="<<i<<endl;
float f1,f2,f;
cin>>f1>>f2;
f=min(f1,f2);
cout<<"f_min="<<f<<endl;
char c1[200],c2[200],c;
cin>>c1>>c2;
c=min(c1,c2);
cout<<"c_min="<<c<<endl;
}
int min(int a, int b)
{
if(a>b) a=b;
return a;
}
float min(float a, float b)
{
if(a>b) a=b;
return a;
}
char * min (char * a, char * b)
{
if(strcmp(a,b)>0) a=b;
return a;
}
cpp(21) : error C2440: '=' : cannot convert from 'char *' to 'char'
There is no context in which this conversion is possible
帮忙看看如何改正,我是初学者
上面的问题我把 char c改为char *c就解决了,但函数重载方面就是无法做好,请高人指点 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询