Can somebody give me real life scenarios in programming?
Posted on March 12th, 2010 by anonym
Use bit fields in a struct.
Use a smart pointer.
Use bit masking.
Use a function pointer.
Language: c++
Smart pointers are safer that normal pointers as they avoid bugs that could be caused by misuse of pointers, these are more useful in situations where computing resources and high performance aren't so important, as they reduce development time.
Bit masking is useful for checking if a particular bit or set of bits, is set or not, see bit fields above..
function pointers are useful when you have multiple functions to do a similar task but for different situations. eg if you make a general method to sort two lists objects you could pass a function pointer as well which is the function which defines what values are put above each other or below each other. so then youd have a function for ints which tests greater than or less than, then a fucntion for strings which checks for alphabetic order....etc
#If you have any other info about this subject , Please add it free.# |