You are ignoring a warning, that is rect is not initialized.But also initialising it will not help.
no there is no such warning (the program runs whithout warnings or errors)
pass by reference in convert function will remove all possible errors.
thanks alot , this worked
but why is that happen why in the first code it works correctly and in the second it doesn't. and why passing by reference works i would like to know more about why im getting this problem than how to solve it :)
rect is passed by value to convert which means it will be copied, so b in convert is a copy of rect in main. Changes made to the copy will not affect the original object so rect stays unchanged. If you pass it by reference instead, changes made to b will affect the object passed to the function which is probably what you want.