Symbian interview questions

Source: Internet
Author: User
1. Use at least three methods for non-C ++ built-in Class A and Class B so that B can be implicitly converted to Class.

2. Briefly describe how to use placement new.

3. Use of the explicit keyword.

Http://blog.csdn.net/pandahsu/archive/2010/03/29/5430004.aspx4?gcis what? Why use GC? Principles

5. Can constructor be a virtual function or a destructor be a virtual function? Why?

6. Briefly describe the factory model in the design mode.

7. Implement a smart pointer class. (Programming)

Symbian part
8. Briefly describe the classes and usage of XML parsing provided by the SDK

9. operating principle of the activity object framework (use the time sequence diagram to draw the call relationship between the activity object and the AS and Asynchronous Server)

10. Can the following code be compiled in s60 2nd (winsw, thumb) and s60 3rd (winsw, gcce? Why (the purpose of this question is to check the differences between the second and third editions)
Class
{
Public:
Void doprint (const tdesc & atext)
{
// Do something ......
}
};
Static const char * thestring = "Hello World ";
Static const tptrc theptr = reinterpret_cast <cast tuint16 *> (thestring );

Local_c void dotestl ()
{
A * A = new (eleave);
A-> doprint (theptr );
} Another 1. describe the implementation principle and causes of the quadratic structure. 2. briefly describe the differences between compound controls and simple controls. 3. briefly describe your understanding of the activity object. 4. briefly describe how to enable auto start for Symbian 2nd and 3rd respectively. briefly describe the differences between s60 and uiq 6. briefly describe the working principle of socket (preferably the implementation of rsocket connected to the network) 7. note the differences between hbufc and tbuf in memory storage 8. briefly describe the concept and solution of Memory leakage 9. note 10. function pointer usage. the role played by the Destructor and virtual in 11.c++ class. 12. it is known that the prototype of the strcpy function is char * strcpy (char * strdest, const char * strsrc );
(1) Implement the strcpy function without calling the library function.
(2) Explain why char * is returned *. Answer: 1. secondary constructor is used to prevent the constructor of an object from generating a leave. These operations that may generate a leave are moved to another function, which is traditionally called contructl (). After the constructor is executed, create an object using contructl (). When executing contructl (), you can use the stack clearing Mechanism to release related resources when leave is generated. 12. explanation: (1 ). implementation Code of strcpy
Char * strcpy (char * strdest, const char * strsrc)
{
If (strdest = NULL) | (strsrc = NULL) // [1]
Throw "invalid argument (s)"; // [2]
Char * strdestcopy = strdest; // [3]
While (* strdest ++ = * strsrc ++ )! = '/0'); // [4]
Return strdestcopy;
}
Incorrect practice:
[1]
(A) if the pointer is not checked, it means that the respondent does not pay attention to the robustness of the Code.
(B) used to check the pointer validity ((! Strdest) | (! Strsrc) or (! (Strdest & strsrc). It indicates that the respondent has no deep understanding of implicit conversions of types in C language. In this example, char * is converted to bool, that is, implicit type conversion. Although this function is flexible, it is more likely to increase the error probability and increase the maintenance cost. Therefore, C ++ adds the bool, true, and false keywords to provide a safer conditional expression.
(C) Use (strdest = 0) | (strsrc = 0) to check the pointer validity. This means that the respondent does not know the benefit of using constants. Directly Using a literal constant (such as 0 in this example) reduces the maintainability of the program. 0 is simple, but there may be a lot of pointer checks in the program. In case of PEN mistakes, the compiler cannot find that the generated program contains logical errors and it is difficult to eliminate them. If null is used to replace 0, the compiler will check if a spelling error occurs.
[2]
(A) return new string ("invalid argument (s)"); it indicates that the respondent does not know the purpose of the returned value, and is not cautious about memory leakage. Returning the memory allocated in the function body from the function is very dangerous. It throws the obligation to release the memory to an uninformed caller. In most cases, the caller will not release the memory, which leads to memory leakage.
(B) Return 0;, indicating that the respondent did not master the exception mechanism. The caller may forget to check the return value, and the caller may not be able to check the return value (see the chain expression below ). If you want the return value to shoulder the dual function of returning the correct value and the exception value, the result is often invalid for both functions. The return value should be replaced by throwing an exception, which can reduce the burden on the caller, prevent errors from being ignored, and enhance the maintainability of the program.
[3]
(A) if you forget to save the original strdest value, it means that the answer provider's logic is not strict.
[4]
(A) cyclically write it as while (* strdest ++ = * strsrc ++);, same as [1] (B ).
(B) cyclically write while (* strsrc! = '/0') * strdest ++ = * strsrc ++;, indicating that the respondent does not check the boundary conditions effectively. After the loop body ends, '/0' is not correctly added to the end of the strdest string '. (2). Return the original strdest value to enable the function to support chained expressions, increasing the "added value" of the function ". Functions of the same function are naturally more ideal if they can reasonably improve availability.
The form of a chained expression is as follows:
Int ilength = strlen (strcpy (stra, strb ));
Another example:
Char * stra = strcpy (New char [10], strb );
The original strsrc value is returned incorrectly. First, the source string must be known and it does not make sense to return it. Second, the expression in the second example cannot be supported. Third, to protect the source string, the const uses const to limit the content referred to by strsrc and returns const char * as char *. If the type is different, an error is returned during compilation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.