• 面试笔试题(1)


    1. 纯虚函数,不能定义变量

    #include <iostream>
    using namespace std;
    class  A
    {
        public:
        virtual void f() = 0;
    };
    int main()
    {
        A a;
        a.f();
        return 0;
    }
    

    2.  虚函数是可以实现的

    #include <iostream>
    using namespace std;
    class  A
    {
        public:
        virtual void f()
        {
            cout << "hello world" << endl;
        }
    };
    int main()
    {
        A a;
        a.f();
        return 0;
    }
    

      3. 纯虚函数是可以实现的

    #include <iostream>
    using namespace std;
    class  A
    {
        public:
        virtual void f() = 0;
    };
    void A ::f()
    {
        cout << " hello world" << endl;
    }
    int main()
    {
        return 0;
    }
    

      4.   f() 是可以在子类中实现的

    #include <iostream>
    using namespace std;
    class  A
    {
        public:
        virtual void f() = 0;
    };
    class B :public A
    {
        public:
        void f()
        {
            cout << "hello world" << endl;
        }
    };
    int main()
    {
        B b;
        b.f();
        return 0;
    }
    

      

  • 相关阅读:
    禅道安装
    logstash将配置写在多个文件
    原版Filebeat+ELK
    Filebeat+ELK部署文档
    A-2---Jenkins安装
    Linux ftp服务器搭建
    linux 网络命令
    yum安装时出现No more mirrors to try.
    kvm 修改虚拟机密码
    NFS安装
  • 原文地址:https://www.cnblogs.com/hitwtx/p/2190570.html
Copyright © 2020-2023  润新知