The essence of "Programmer Interview Guide" is the object-oriented part, a programmer Interview Guide

Source: Internet
Author: User

The essence of "Programmer Interview Guide" is the object-oriented part, a programmer Interview Guide
Programmer interview book (object-oriented)

  • The essence is called to get its dregs. This article keeps in mind some key knowledge points and error points recorded in the programmer interview guide, and does not record some important points that are not clearly explained in the book. There is no scum in the book, but it only refers to a less important or relatively simple place, it is not to say that writing is not good. I hope you don't need to read this book again later. You just need to read the essence of the book.
  • There are a few bugs in this article, which are also excerpted here.
  • This article focuses on the object-oriented part, including chapter 10 to Chapter 11th.
Chapter 10 object-oriented
  • 10.2 differences between a class and a struct: All member functions can be inherited and have destructor. The only difference is that the struct member is public by default, while the class is private by default. C ++ reserves the struct keyword to be compatible with C code.
  • 10.3class B{...}; B b(); b.f();Yes. B is declared as a function.
  • 10.3 static member variables must be explicitly initialized, for exampleint A::i 0;
  • 10.3 The initialization sequence of member variables is irrelevant to the initialization list sequence and related to the variable declaration sequence.
  • The member variables of the 10.3 constant (cosnt) must be initialized in the initialization list of the constructor or declaredstatic constMember
  • 10.4 declaring a member function as a virtual function increases the call overhead. Why do I often declare the basic class destructor as a virtual function: in the case of polymorphism, the pointer of the derived class object is often assigned to the Base Class pointer. Therefore, the virtual function is used to ensure that the destructor of the derived class object can be called during the delete operation without causing memory leakage.
  • 10.4 why cannot a constructor be declared as virtual: a virtual call is used to call a member function that only knows the interface but does not know its object type. when instantiating an object, you must know the exact type of the object, therefore, the constructor cannot be virtual (suspect, not clear enough)
  • 10.4 when function f returns an object, useA t = f()To call the copy constructor. That is, when both function parameters and return values are objects, a copy constructor is called.
  • 10.4 constructor containing a single parameter defines an implicit type conversion from the parameter type to the class. The explicit keyword can be used to avoid this conversion.
  • 10.5 function parameters are often declared as const, because the const variable cannot be converted to non-const at will, and vice versa.
  • 10.5 each object of the class must have a unique id. You need to customize the copy constructor to avoid duplication.
  • 10.5 If the class contains dynamically allocated pointers, You need to define the copy constructor and value assignment function.
  • 10.6 what is polymorphism?
    • Concept: encapsulation, inheritance, and polymorphism are three basic concepts of OO. Polymorphism means that the subclass type can be assigned to the parent class pointer, and the parent class pointer can operate on all the subclass objects through a unified interface.
    • Purpose and purpose: encapsulate the existing code modules to hide implementation details, unify data types and functions, and modularize them. inheritance is to facilitate the expansion of existing code modules. Both can achieve code reuse, polymorphism is used to achieve interface reuse.
    • Implementation Method: virtual functions
  • 10.6 rewrite and overload. The former override refers to the virtual function of the subclass to redefine the parent class, and the latter overload refers to the function with different names in multiple parameter lists at the same time.
Chapter 2 Inheritance and interfaces
  • 11.1 if you explicitly call a virtual function, the virtual call mechanism becomes invalid, as shown in figureclass B::public A{}; B b; b.A::f();Class f is A virtual function, but the f in Class A is explicitly called
  • 11.2 differences between the three inheritance Methods
    • Public inheritance: the public and protected members of the base class maintain the original state of the base class.
      • Visibility of base class members on the derived class: The derived class (member function) can access the public and protected members of the base class.
      • The visibility of the base class members on the objects of the derived class: (through) The object of the derived class (for exampleA. f () method) You can access the public members of the base class.
    • Private inheritance: the public and protected members of the base class are treated as private members of the derived class and cannot be accessed by the subclass of the derived class.
      • Visibility of base class members on the derived class: The derived class (member function) can access the public and protected members of the base class.
      • Visibility of base class members on the objects of the derived class: (through) The objects of the derived class cannot access any member of the base class, so the members of the base class cannot inherit down.
    • Protected inheritance: the public and protected members of the base class are treated as the protected members of the derived class and cannot be accessed by the subclass of the derived class.
      • Visibility of base class members on the derived class: The derived class (member function) can access the public and protected members of the base class.
      • Visibility of base class members on the objects of the derived class: (through) The objects of the derived class cannot access any member of the base class, so the members of the base class cannot inherit down.
    • The key difference is that the derived class object can access the members of the base class, and whether the subclass of the derived class can access the members of the derived class.
  • 11.2 differences between three member attributes: The private member of the base class shields the derived class, and the protected member makes the derived class accessible. Only the public Member of the base class can access the base class through the object of the base class.
  • 11.2 virtual inheritance is used to solve the diamond inheritance conflict in multiple inheritance. A pointer pointing to the base-class virtual function table is added to the derived class.
    • For example, if C and B are inherited from A, and D is inherited from B and C, D contains
  • 11.4 use interfaces in Java to replace multiple inheritance. C ++ can use abstract classes to simulate interfaces.
  • 11.4 C inherits from A, B, and pC pointing to the C object. If pB converts the pC pointer to BpC == pBHere, the implicit conversion from the pointer of C to the pointer of B occurs. The book says the opposite, bug
  • The default value of class 11.5 is private, and the public keyword is usually required.
  • 11.6 how to prevent class instantiation: use an abstract class with pure virtual functions, or declare the constructor as private
  • 11.7 disadvantages of RTTI: Besides running overhead, the program becomes uncertain and lacks scalability.
  • 11.7 The type conversion operator is overloaded. If no return value is set, no parameter is required. The target type is used as the function name, for example:operator char*()
  • 11.8 if the conversion fails, dynamic_cast returns 0.
  • 11.8 The Return Value of typeid is a reference to the type_info constant object.

  
  

Reprinted by: Focustc. The blog address is http://blog.csdn.net/caozhk. The original link is opened by clicking
  
  
C/C ++ interview questions. If it is good, add points as soon as possible.

I have a book titled the programmer interview book, which I will show you. If you feel better, don't forget to score

Q: What is the third edition of the programmer interview guide? Which version is more comprehensive?

It is more suitable for the company's interview questions and concerns.

This book is the third edition of the programmer interview book.
The third edition mainly involves updates. On the basis of retaining the data structure, object orientation, and program design of the original book, a large number of program design examples are updated. To reflect the changes that have taken place in the past few years since the first version of the market, it helps job seekers better deal with new problems and changes.
The new changes in this book are as follows:
Based on the three sections of the original book (written examination, telephone interview, and interview), this chapter adds two sections (Contract Signing and default) to the job application process ), in order to better help job seekers deal with the troubles of some details during the job search process.
For the C/C ++ program design, most examples are updated. For example, in the original book, cyclic queue problems were repeatedly mentioned during the interview, but in the past two years, such problems as reverse-cyclic queue and zigzag also frequently occurred during the interview. For example, recursive interviews have rarely encountered overly-common Fibonacci problems, instead of constructing multi-tree recursion and diagonal value, we have expanded and rewritten these issues in the third edition.
For new questions in the interview, this book adds new chapters: Non-or, youyuan, Static, graphics/audio, tree, stack, ERP, group interview, and so on. Compared with the previous version, the content of the third edition is closer to market changes and keeps pace with the times.
The programmer interview book is different from similar books in its main features:
Fine
Chinese software companies are relatively small, and there are many interview aspects and basics. For example, some basic programming interview examples are often obtained, but the original interview books Rarely touched on this aspect. This book puts the most easily tested basic test points for domestic companies in Part 2 C ++ BASIC program design, hoping to effectively solve practical interview problems.
Private
The interview questions examine the ability of a specific category through a single question. For example, the keyword volatile interview example is to examine embedded programming. From the interviewer's perspective, a test may reveal the examinee's quality and level in many aspects. Because of this, this book will carefully classify test sites (embedded programming, basic code, object-oriented, template, etc.), and improve the reader's ability to master these aspects through interview examples, to achieve targeted results.
Guang
Job applicants generally have three types of positions: network engineers, test engineers, and software developers. For example, Trend Micro, Huawei 3COM, Cisco, and other companies have increasingly questions about programs and networks. In addition, with the entry of the world's top five hundred enterprises, foreign companies are more interested in design patterns, software measurements, and other questions, but there are few reviews on the market. This book analyzes the characteristics of a large number of questions and details the test plan to meet market needs.
True
On the basis of keeping the original book trunk, the third edition has a very new content and can be used as a full simulation of the interviewer's job. At the same time, the author integrates the details (resume, recruitment, contract signing, and breach of contract) in the job, as well as the sentiment in the written examination and interview, to give the job seeker the most sincere humanistic care. The true feelings and true feelings allow readers to embark on the ideal job. This book is not a omnipotent book, but it must be a good assistant and a good partner for your work and job search!

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.