zoukankan      html  css  js  c++  java
  • C++第五章理论题经验整理1

    Destructors are automatically invoked when an object goes out of scope or when a dynamically allocated object is deleted. Inheritance does not change this behavior. This is the reason a derived destructor cannot invoke its base class destructor.

    Which constructor will initialize the base class data member?  base class

    Classes that contain at least one pure virtual function are called as abstract base classes.

    We cannot make an instance of an abstract base class.

    As base class only as it helps in encapsulation of similar functioning of derived classes.

    As we are allowed to declare a pointer object of an abstract so the program does not give any compilation error but as there is no definition of func() function corresponding to class A, therefore, the program gives segmentation fault as it is not able to call such function from class A.

    Class hierarchies promote reuse in two ways. They are code sharing and interface sharing.

    There are three types of classes. They are abstract base classes, concrete derived classes, standalone classes.

    Inheritance helps in creating hierarchy of classes by making connections between different classes in which one is called base class and other is class derived class.

    There are five types of inheritance in c++. They are single, Multiple, Hierarchical, Multilevel, Hybrid.

    Container ship is a class contains objects of other class types as its members.

    The derived class inherits everything from the base class except constructor and destructor,  friends,  operator = () members


    Templates are used for creating generic classes to handle different types in single classes.

    There are two types of templates. They are function template and class template.

    The compiler can determine at compile time whether the type associated with a template definition can perform all of the functions required by that template definition.

    The name of the parameter that the template should take same as the template.

    The following are legal for non-type template parameters: integral or enumeration type, Pointer to object or pointer to function, Reference to object or reference to function, Pointer to member.

    During runtime, We can choose the appropriate type for the function and it is called as template type parameters.

    Non-type template parameters provide the ability to pass a constant expression at compile time. The constant expression may also be an address of a function, object or static class member.

    C++ allows to overload template functions with normal functions therefore the program does not gives any error. When program is executed then int b = func(a); calls the normal function whereas float c = func(5.5) calls the template function.

    template有时可以用auto来对type进行替换

     A template parameter is a special kind of parameter that can be used to pass a type as argument.

    Template parameters are valid inside a block only i.e. they have block scope.

    function template overloading is similar to template specialization.

    explicit specialization is another name of full specialization.

    Base class is dependant on template parameter.

    C++ allows us to parameterize directly three kinds of entities through templates: types, constants, and templates.

    There are three kinds of parameters are there in C++. They are type, non-type, template.

    STL has four components namely Algorithms, Containers, Functors and Iterators.

    Containers are divided into 4 categories namely Sequence Containers, Associative Containers, Unordered Associative Containers and Container Adaptors.

    Sequence Containers is the subset of Containers that implements data structures which can be accessed sequentially.

    C++ provides 5 types of Sequence Containers namely array, vector, deque, forward_list and list.

    Associative Containers is the subset of Containers that implements sorted data structures for fast search in O(logn).

    C++ provides 4 types of Associative Containers namely Set, Map, multiset and multimap.

    Unordered Associative Containers is the subset of Containers that implements unsorted(hashed) data structures for quick search in O(1) amortized O(n) Worst case complexity.

    Container Adaptors is the subset of Containers that provides a different interface for sequential containers.

    C++ provides 3 types of Container Adaptors namely Stack, Queue and Priority Queues.

     There are five types of Iterators provided by C++ namely Input Iterators, Output Iterators, Forward Iterators, Bi-directional Iterators and Random-access Iterators.

  • 相关阅读:
    [ Algorithm ] N次方算法 N Square 动态规划解决
    [ Algorithm ] LCS 算法 动态规划解决
    sql server全文索引使用中的小坑
    关于join时显示no join predicate的那点事
    使用scvmm 2012的动态优化管理群集资源
    附加数据库后无法创建发布,error 2812 解决
    浅谈Virtual Machine Manager(SCVMM 2012) cluster 过载状态检测算法
    windows 2012 r2下安装sharepoint 2013错误解决
    sql server 2012 数据引擎任务调度算法解析(下)
    sql server 2012 数据引擎任务调度算法解析(上)
  • 原文地址:https://www.cnblogs.com/hhlys/p/13493415.html
Copyright © 2011-2022 走看看