Paper Details  
 
   

Has Bibliography
22 Pages
5416 Words

 
   
   
    Filter Topics  
 
     
   
 

Exam tests

assist in the management of globals. Explain how poor naming practices for variables can lead to "holes" in the scope of a variable. (1 mark) If an int tom, has function scope a hole can be made inside this function by the declaration of char tom inside of a while loop scope. This poor naming convention leads to very difficult debugging and maintenance coding. Explain why a compiler may have to insert "padding" bytes into C/C++ structs. (1 mark) Many CPU architectures have addressing limitations, ie an 8 byte data structure must be located at an address divisible by 8. Therefore some c/c++ structures may need padding inserted by the compiler to allow for this. Explain the role of "unions" and illustrate the code for using the appropriate member of a union. (1 mark) Code using a union is typically a function that takes a union (or a union*), checks in some way to find type its working with, and then calls appropriate processing function.void DoProcessing(Example anExample){ switch(anExample.fType) {case kCOORDTYPE: ProcessCoord(anExample.fT1.fX, anExample.fT1.fY); break;case kCHARKEYTYPE: ProcessCharKey(anExample.fT2.fN2); break;…Explain why "typedefs" fail to offer much type security. (1 mark)Typedef type and original type are not distinguished by compiler Sketch either the C or C++ code that would allow calling code to first create a data structure referenced by a pointer, and then pass the pointer to a function in such a way that the called function can if necessary substitute a new object for the object originally referenced by the caller's pointer. (2 marks) struct cake;void Mix(cake*); …cake* mud = new cake;Mix(mud);…Explain why the following code is erroneous: char *GetName() { char buff[256]; // code prompting user for input and reading a string into buff ... return buff; } Returns an automatic variable which would fall out of scope wh...

< Prev Page 3 of 22 Next >

    More on Exam tests...

    Loading...
 
Copyright © 1999 - 2025 CollegeTermPapers.com. All Rights Reserved. DMCA