Tuesday, February 12, 2008

The Smurfette, Pain au Raisin, Rummy and Returning arrays from Fns.

The pairs of extra brackets in Scheme are actually not 'extra' they are needed as per syntactic rules... that's one troubling thing down the line.....

Had a programming revision class today, and at times I got gazes like those in the HiSense Advert on TV. Some were so annoyed that they started throwing the CPUs around..... We have 4 CPUs accidentally falling off their racks... 'Comme Quoi certain(es) expriment leur frustration dans les laboratoires'.. fortunately no one got hurt, but i think the target was.........me... Nah kidding!!!!

So if you work in the CITS lab someday, and your PC is not working... it could also be the case that some Management with IS student used it before you!!! :-)

My lunch break today consisted of 'Pain au Raisin & Fanta & Yop Rumba!!!', for dessert i had a game of Rummy in the Cafetaria. Lost the first game and won the second one in just 2 turns... too good... (Definitely not a balanced diet!!!)

Hey by the way i saw the 'Girl in the Orange top' today except that she was a Smurfette, and she had matching earings. She's blue.. di da di da di di dou.. di da di dam di di dou (....Eiffel 65 moment...)... anyways!!!

When I got back to my office the (supposedly) 'Méchante Miss' did not keep my share of mangoes.... sniff sniff snifff!!! :'-(

Now let's get interesting... i discovered quite a few thing today.... Visual C++ made it hard for me to return a string of text from a member function, but i used a pointer instead... thats the first part.

Anyways for those who cannot understand, we use the following to return a string of text

char * x::get_name()
{
return A;
//where A is a string of text
}

Then in main we can have strcpy( Z, c.get_name() )
//where c is an instance of the class x.

Now we'll assume that an attribute of a class is an integer array, how can we return this array to the main function?????

One option would be to return the pointer to that array but thats not really cool.

Could we not have someting like

int [] X::get_array_A()
{
return A;
//where A is an array
}
But then we would have to copy the whole array A to another array....

AAAHAAAA!!!! (That was a genuine Aahhaaaa moment!) What if we pass an array as parameter in the function as shown below

void X::get_array_A(int copy_of_A[])
{
for(i=0;i<...;i++)
{
copy_of_A[i]=A[i];
}
}


Since arrays behave as if they are passed by reference, when the values of copy_of_A change in the function get_array_A(), the new values will be reflected in main... sounds Brilliant and Crafty but i need to test it........

Come on you could have thought about that!!!!!

Will let u know tomorrow if it really works....

By the way plan 'Mine Bouillie Gros Pois' demain... cool!!!!

G@V!N

No comments: