C + + Interview topic analysis

Source: Internet
Author: User

1. The difference between a pointer and a reference

Answer: A, the pointer can be modified, the reference cannot be changed.

B, the pointer occupies memory, the reference does not occupy memory.

C, references cannot be null pointers can be null.

2. The difference between memcpy and strcpy

A: The strcpy will be copied to the/end string copy

memcpy is a memory copy

3. struct and class differences

A: By default, the access modifier is struct:public class:private

Default to inherit from struct is public

Storage type struct stored in the order of member declaration class cannot be saved

4, memory allocation method and the difference that is what the memory, what to do

A: heap, stack, code area, static storage (constant area)

Constant zone-"global variable, static variable, will be assigned at compile time

Stack-"Local variables, parameters, and function returns are all recorded in the stack

Heap area-"malloc Free new Delete programmer management

New malloc Difference

1. malloc is a function (cannot be overloaded) new is an operator (can be overloaded)

C + + Four modules comprise: 1, c 2, Object-oriented C + + 3, module C + + 4, STL

In a C + + program:

String C + + Standard library C + + standard library STL std:string header file

String.h C Standard Library

CString C standard library is adapted to the C + + standard

C + + Interview topic analysis

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.