From: http://hi.baidu.com/qrs1/blog/item/c4b5dbcd0fa0d2590fb345e5.html
1. What are output by the following three output statements? [C ease]
Char str1 []= "Abc ";
Char str2 []= "Abc ";
Const char str3 [] = "abc ";
Const char str4 [] = "abc ";
Const char * str5= "Abc ";
Const char * str6= "Abc ";
Cout <boolalpha <(str1 = str2) <endl; // What is output?
Cout <boolalpha <(str3 = str4) <endl; // What is output?
Cout <boolalpha <(str5 = str6) <endl; // What is output?
2. Where can B be implicitly converted to A for non-C ++ built-in types A and B? [C ++ medium]
A:
A. class B: public {......} // The Public B inherits from A and can be indirectly inherited.
B. class B {operator A ();} // B implements implicit conversion to
C. Class A {A (const B &) ;}// a constructor that implements the non-explicit parameter as B (other parameters with default values can be available)
D. A & operator = (const A &); // value assignment operation. Although it is not an authentic implicit type conversion operation, it can barely calculate
3. Are there any problems with the usage of the two sizeof in the following code? [C ease]
Void uppercase (char STR []) // converts lowercase letters in STR to uppercase letters.
{
For (size_t I = 0; I <sizeof (STR)/sizeof (STR [0]); ++ I)
If ('A' <= STR [I] & STR [I] <= 'Z ')
STR [I]-= ('A'-'A ');
}
Char STR [] = "ABCDE ";
Cout <"str character length:" <sizeof (STR)/sizeof (STR [0]) <Endl;
Uppercase (STR );
Cout <STR <Endl;