You are doing a code review. A programmer has written the following function, which uses unnecessary temporary objects in at least three places. How many can you identify, and how should the programmer fix them?
string FindAddr( list
Maybe try it on StackOverFlow
Software Engineering exam?
No, not exam.....just a puzzle.............:D Try it.....:D
@Gary: Its a puzzle dear...:D
it is a diffficult 1
No, not at all. It is fairly easy, if basic programming concepts are clear.......:D
I'll just try this out, delete random stuff, and see if it still works :-D
or maybe this is some huge trick question that can be solved with some nice library function?
it is very very easy dude......:D There is no need to try it using a compiler + IDE...........:P
or is it passing by value things that is better to pass by referece like some objects?
yeah 'unnecessary temporary objects' instead of the whole list just pass an address
and make it readonly
Behavior should not be changed!!!!!!!!!!!
yeah why would behavior change if you pass a simple readonlyreference?
you are close to answer...go ahead...........:D
return ""; I think instead of doing this, just use addr
wow, something else?
I think the rest are more subtle and relate to C++ operations on objects making temporary stuff.
Compared to C, C++ is more complex :-D
gary of course it's difficult if you don't know C++ language
I'm sure this stuff is elementary stuff out of a good C++ textbook, which I will read once I'm done with learning C.
This stuff is not from a textbook!!
Join our real-time social learning platform and learn together with your friends!