zoukankan      html  css  js  c++  java
  • founder面试题

    1.写出正面程序支行结果:
    #include<iostream>
    using namespace std;
    void func(int a)
    {
        static int c = a;
        c++;
        cout << c << endl;
    }
    
    void main()
    {
        func(15);
        func(17);
    }
    结果:16
         17
    
    2.对于正面代码,请写出运行结果:
    #include<iostream>
    using namespace std;
    class A{
    public:
        virtual void func1(){ cout << "A::func1" << endl; }
        void func2(){ cout << "A::func2" << endl; };
    };
    class B :public A
    {
    public:
        void func1(){ cout << "B::func1" <<endl; }
        void func2(){ cout << "B::func2" << endl; }
    };
    void main()
    { 
        B x;
        B* pB = &x;
        A* pA = &x;
        pB->func1();//调用的是哪个方法
        pB->func2();//调用的是哪个方法
        pA->func1();//调用的是哪个方法
        pA->func2();//调用的是哪个方法
    }
    结果:
    B::func1
    B::func2
    B::func1
    A::func2
    3.字节对齐:
    #include<iostream>
    using namespace std;
    struct A{
        bool bA1;
        bool bA2;
        int nA;
        bool bA3;
    };
    struct B{
        bool bB1;
        bool bB2;
        bool bB3;
        int nB;
    };
    void main()
    {
        cout << sizeof(A) << endl;
        cout << sizeof(B) << endl;
    }
    结果:
    12
    8
  • 相关阅读:
    hive 调优
    nohup
    安装ElasticSearch 6.1.1 head插件
    101. Symmetric Tree
    67. Add Binary
    70. Climbing Stairs
    896. Monotonic Array
    66. Plus One
    27. Remove Element
    Apache Tomcat文件包含漏洞风险大,威胁全球约8万台服务器
  • 原文地址:https://www.cnblogs.com/timssd/p/4088547.html
Copyright © 2011-2022 走看看