zoukankan      html  css  js  c++  java
  • C++ OOP Concept 3错题

    C++ allows both static and dynamic type checking i.e. types are checked by the compiler.

    As we will be using the existing code therefore we don’t need to check the code again and again so testing and maintenance time decreases but the compiler time may increase or remains same because though we are reusing the code but every part needs to be compiled and extra include statement needs to be executed therefore compilation time may remain same or increases.

    6. Which of the following is a static polymorphism mechanism?
    a) Function overloading
    b) Operator overloading
    c) Templates
    d) All of the mentioned

    A:All the options mentioned above uses static polymorphism mechanism. As the conflicts in all these types of functions are resolved during compile-time.

    9. What happens if a class does not have a name?
    a) It will not have a constructor
    b) It will not have a destructor
    c) It is not allowed
    d) It will neither have a constructor or destructor

    A:A class without a name will not have a destructor. The object is made so constructor is required but the destructor is not. Check the code below:

    #include <iostream>
    using namespace std;
    class
    {
        public:
        void func()
            {
            cout<<"Hello world";
        }
    }a;
    int main(int argc, char const *argv[])
    {
        a.func();
        return 0;
    }

    In Procedural programming like C we don’t have the concept of polymorphism, therefore, all the function calls are resolved at the compile-time but in case of OOP languages sue to polymorphism concept all function calls are not resolved at compile-time.

    Friend functions can access any member of a class without caring about the type of member i.e. without caring whether it is private, protected or public.

    Abstract class should have at least one pure virtual function. Therefore to declare an abstract class one should declare a pure virtual function in a class.

    An object is an instance of a class i.e. an object represents a class i.e. what class has(data members) and what it can do(member functions).

  • 相关阅读:
    git gui 学习
    Java中关于 ArrayList 和 Map 的常用遍历方法 (学习笔记,便于以后查询)
    关于对 NUMA 理解(学习笔记,便于以后查阅)
    Java判断数据库表是否存在的方法
    流程开发Activiti 与SpringMVC整合实例
    shiro权限管理框架与springmvc整合
    Java开发中的23种设计模式详解(转)
    JMS学习之路(一):整合activeMQ到SpringMVC
    SpringMVC中定时任务配置
    RPC远程过程调用学习之路(一):用最原始代码还原PRC框架
  • 原文地址:https://www.cnblogs.com/hhlys/p/13062978.html
Copyright © 2011-2022 走看看