Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binary Operator Overloading

Status
Not open for further replies.

Liam0003

Technical User
Jan 27, 2002
1
US
I am overloading + in a simple effort to combine two number sequences; for example:
a=1,2,3
b=4,5,6

The output that I want is to have a third sequence combine them like this:
c=1,2,3,4,5,6

When I try to do this, I receive error C2664 which is saying cannot convert number type a to number type b.

Any ideas?
 
i am assuming that a & b are character arrays? If so, you could just use the "CString" class. If they are numeric arrays then a loop would be required to write them to a string. Something like

CString begin,end;
for(int i = 0;i < 3; i++)
{
CString tmp;
tmp.Format(&quot;%d,&quot;,a);
begin += tmp;
tmp.Format(&quot;%d,&quot;,b);
end += tmp;


}

CString final = begin + end;

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top