error C2665: 'add' : none of the 2 overloads can convert parameter 1 from type 'struct plura'
#include<iostream>usingnamespacestd;structplura{floatcomplex;floatimaginaryPart;};voi...
#include<iostream>
using namespace std;
struct plura
{
float complex;
float imaginaryPart;
};
void add(int n,int i,int &sum);
void add(struct plura n,struct pluar i,struct plura & sum);
int main()
{
int Number1,Number2,NumberSum;
plura Plura1,Plura2,PluraSum;
cout<<"input int number1 and number2:";
cin>>Number1>>Number2;
cout<<"input plura1";
cin>>Plura1.complex>>Plura1.imaginaryPart;
cout<<"Plura2:"<<endl;
cin>>Plura2.complex>>Plura2.imaginaryPart;
add(Number1,Number2,NumberSum);
cout<<NumberSum;
add(Plura1,Plura2,PluraSum);
cout<<PluraSum.complex<<'+'<<PluraSum.imaginaryPart<<'i'<<endl;
return 0;
}
void add(int n,int i,int &sum)
{
sum=n+i;
return ;
}
void add(struct plura n,struct plura i,struct plura &sum)
{
sum.complex=n.complex+i.complex;
sum.imaginaryPart=n.imaginaryPart+i.imaginaryPart;
return ;
}
--------------------Configuration: 1-10 - Win32 Debug--------------------
Compiling...
1-10.cpp
f:\1-10.cpp(22) : error C2665: 'add' : none of the 2 overloads can convert parameter 1 from type 'struct plura'
Error executing cl.exe.
1-10.exe - 1 error(s), 0 warning(s) 展开
using namespace std;
struct plura
{
float complex;
float imaginaryPart;
};
void add(int n,int i,int &sum);
void add(struct plura n,struct pluar i,struct plura & sum);
int main()
{
int Number1,Number2,NumberSum;
plura Plura1,Plura2,PluraSum;
cout<<"input int number1 and number2:";
cin>>Number1>>Number2;
cout<<"input plura1";
cin>>Plura1.complex>>Plura1.imaginaryPart;
cout<<"Plura2:"<<endl;
cin>>Plura2.complex>>Plura2.imaginaryPart;
add(Number1,Number2,NumberSum);
cout<<NumberSum;
add(Plura1,Plura2,PluraSum);
cout<<PluraSum.complex<<'+'<<PluraSum.imaginaryPart<<'i'<<endl;
return 0;
}
void add(int n,int i,int &sum)
{
sum=n+i;
return ;
}
void add(struct plura n,struct plura i,struct plura &sum)
{
sum.complex=n.complex+i.complex;
sum.imaginaryPart=n.imaginaryPart+i.imaginaryPart;
return ;
}
--------------------Configuration: 1-10 - Win32 Debug--------------------
Compiling...
1-10.cpp
f:\1-10.cpp(22) : error C2665: 'add' : none of the 2 overloads can convert parameter 1 from type 'struct plura'
Error executing cl.exe.
1-10.exe - 1 error(s), 0 warning(s) 展开
2个回答
展开全部
void add(struct plura n,struct plura i,struct plura & sum);
注意拼写。
注意拼写。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//compiled by g++
#include<iostream>
#include<conio.h>
using namespace std ;
void witch( int * ,int*);
void witch( double ** , double ** );
void show(double []);
int main()
{ int A =1 , B=2 ;
double C[2]=;
double D[2]=;
double *pt1=C,*pt2=D; //amend here
cout<<A<<" "<<B<<endl ;
show(C);
show(D);
witch(&A,&B);
witch(&pt1,&pt2);
cout<<A<<" "<<B<<endl ;
show(pt1); //amend
show(pt2); //amend
getch();
return 0;}
void witch ( int *m,int *n )
{ int L;
L=*m ;
*m=*n;
*n=L;
return ; }
void witch ( double **M , double **W )
{ double *p ;
p=*M;
*M=*W;
*W=p;
return ;}
void show(double X[])
{for(int i=0;i<2;i++)
cout<<X[i]<<" ";
cout<<endl;
return ;}
#include<iostream>
#include<conio.h>
using namespace std ;
void witch( int * ,int*);
void witch( double ** , double ** );
void show(double []);
int main()
{ int A =1 , B=2 ;
double C[2]=;
double D[2]=;
double *pt1=C,*pt2=D; //amend here
cout<<A<<" "<<B<<endl ;
show(C);
show(D);
witch(&A,&B);
witch(&pt1,&pt2);
cout<<A<<" "<<B<<endl ;
show(pt1); //amend
show(pt2); //amend
getch();
return 0;}
void witch ( int *m,int *n )
{ int L;
L=*m ;
*m=*n;
*n=L;
return ; }
void witch ( double **M , double **W )
{ double *p ;
p=*M;
*M=*W;
*W=p;
return ;}
void show(double X[])
{for(int i=0;i<2;i++)
cout<<X[i]<<" ";
cout<<endl;
return ;}
追问
请问您能解释我的那个问题么??错误在哪里??错误是什么意思??该如何改正?谢了!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询