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? 0
Cout <boolalpha <(str3 = str4) <Endl; // What is output? 0
Cout <boolalpha <(str5 = str6) <Endl; // What is output? 1
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------
In which situations 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
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------
Is there a problem 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;
Because sizeof (STR) is always 4 after the parameter is passed
Certificate ---------------------------------------------------------------------------------------------------------------------------------------------
What is the problem with the following code? [C ++ ease]
Struct Test
{
Test (INT ){}
Test (){}
Void fun (){}
};
Void main (void)
{
Test A (1 );
A. Fun ();
Test B ();
B. Fun ();
}
When calling the default function of the structure, do not () such as test;
Certificate ---------------------------------------------------------------------------------------------------------------------------------------------
What is the problem with the following code? [C ++ ease]
Cout <(true? 1: "1") <Endl;
? The two return values must be of the same type.
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------
Unsigned int const size1 = 2;
Char str1 [size1];
Unsigned int temp = 0;
Cin> temp;
Unsigned int const size2 = temp;
Char str2 [size2];
The first is right, and the second is wrong.
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------
Struct CLS
{
Int m_ I;
CLS (int I): m_ I (I ){}
CLS ()
{
CLS (0 );
}
};
Cls obj;
Cout <obj. m_ I <Endl;
Is certainly not able to get the output result of 0, because the call in the constructor is another object created in the memory
Certificate ----------------------------------------------------------------------------------------------------------------------------------------------