Pretty funny how you react to this stuff....
BTW, your code wouldn't compile . Here are the errors from the compiler:
Build
[C++ Error] Unit1.cpp(28): E2268 Call to undefined function '_D'
[C++ Error] Unit1.cpp(30): E2015 Ambiguity between '_fastcall System::operator +(int,const System::Variant &)' and '_fastcall System::operator +(int,const System::Currency &)'
[C++ Error] Unit1.cpp(38): E2015 Ambiguity between '_fastcall System::operator +(int,const System::Variant &)' and '_fastcall System::operator +(int,const System::Currency &)'
[C++ Warning] Unit1.cpp(55): W8070 Function should return a value
So why num and nums are in the header is so they wouldn't fall out of scope, as I placed them under a second button. This time they both came out zeros(?)
And I didn't try to rewrite his method, I simply removed the couts so I could just run the function().
But thanks for your input. It was more than enlightening.
//----------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int i, nums[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
for(i = 0; i < 10; i++)
square(nums, 10);
for(i = 0; i < 10; i++)
return ;
}
//---------------------------------------------------
int __stdcall TForm1:: square(int *n, int num)
{
while(num)
{
*n = *n * *n;
num--;
n++;
}
return num;
}
//----------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Label1->Caption = IntToStr(nums);
Label2->Caption = IntToStr(num);
}