[Collection] classical C/C ++ interview questions (2)

Source: Internet
Author: User

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 cout cout

2. Which of the following conditions can B be implicitly converted to a for non-C ++ built-in types A and B? [C ++ medium]
answer:
A. Class B: Public {......} // The Public B inherits from a, which can be indirectly inherited
B. class B {operator A () ;}// B implements implicit conversion to a
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, you can barely calculate it as a

3. Are there any problems with the usage of the two sizeof in the Code below? [C easy]
void uppercase (char STR []) // converts lowercase letters in STR into uppercase letters
{< br> for (size_t I = 0; I If ('A' <= STR [I] & STR [I] <= 'Z ')
STR [I]-= ('A'-'A');
}< br> char STR [] = "ABCDE ";
cout <"str:" uppercase (STR );
cout

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.