Hey Guys
I am trying to get a basic program to work with dynamic memory allocation.
I have a problem with a overload operating my stream operator...<<
On my previous program i used this:
ostream& operator<<(ostream& output, const Vector& p)
{
output << "(" << p.x << ", " << p.y <<", " << p.z << ")";
return output;
}
The new program is using a dynamically allocated array - what i am trying to do is:
void operator<<(float *p, int arraySize)
{
cout << "(";
for (int i = 0; i < arraySize; i++)
cout << "(" << p[i];
cout << ")";
}
Would this sort of thing work? Im assuming not as it obviously doesnt when i try running the program with this line:
const Vector v1;
cout << "v1: " << v1 << endl;
The 2nd program i think should have 3 arguments for the function overload... the ostream object, the floater pointer to the array, and the array size... right? Could someone help me out?
Thank you ... your help is appreciated as always