99b Subj : Re: Need help, please! To : borland.public.cpp.borlandcpp From : "Ed Mulroy [TeamB]" Date : Tue Nov 25 2003 12:52 pm A simple array contains no information on its size and unless I misunderstand something one cannot overload built in operators for native types. You must be speaking of a some kind of container which represents an array and which can report its size. C++ provides the container class vector so I'll use that. As IDE builds and GUI output cannot be shown in a newsgroup message, here is a screen capture of an example done as a console mode program built from the command line. ----------------------- C:\Lookat\q420 >type q420.cpp #include #include #include using namespace std; typedef vector DbleVect; DbleVect operator - (const DbleVect& d1, const DbleVect& d2) { int num1 = d1.size(); int num2 = d2.size(); if (num1 > num2) num1 = num2; DbleVect result; for (int i = 0; i < num1; ++i) { result.push_back(d2.at(i) - d1.at(i)); } return result; } int main() { DbleVect a; DbleVect b; DbleVect c; randomize(); for (int i = 0; i < 10; ++i) // populate the vectors { a.push_back(rand() / 10.0); b.push_back(rand() / 10.0); } c = b - a; for (int i = 0; i < 10; ++i) // display results { printf("%0.2f - %0.2f = %0.2f\n", a[i], b[i], c[i]); } return 0; } C:\Lookat\q420 >bcc32 -WCR -v q420 Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland Q420.CPP: Turbo Incremental Link 5.64 Copyright (c) 1997-2002 Borland C:\Lookat\q420 >q420 2913.10 - 2786.00 = 127.10 1756.80 - 3273.70 = -1516.90 754.30 - 2349.70 = -1595.40 2177.10 - 2254.10 = -77.00 407.10 - 1112.10 = -705.00 1741.80 - 589.30 = 1152.50 2564.30 - 511.80 = 2052.50 2004.60 - 2991.90 = -987.30 2212.90 - 1193.00 = 1019.90 2647.70 - 2474.80 = 172.90 C:\Lookat\q420 > ----------------------- .. Ed > Bojidar Markov wrote > news:3fc36926$1@newsgroups.borland.com... > > It seems you didnt understand my request. > I was asking someone to help me with this task which have to > be made in C++ (this is why im posting here), not in Delphi (if > it was in Delphi i wouldn't asking at all). > > Still looking forward for a help... . 0