全部知识点

第5981题

下列关于函数重载的叙述中,错误的是()。

第5982题

 以下程序的执行结果是()。

#include<iostream.h>
class TestClass2
{
public:
    TestClass2(){};
    TestClass2(int i,int j);
    void printb();
private:
    int a,b;
};
class TestClass1
{
public:
    TestClass1(){}
    TestClass1(int i,int j);
    void printa();
private:
    TestClass2 c;
};
TestClass1::TestClass1(int i,int j):c(i,j)
{}
void TestClass1::printa()
{
    c.printb();
}
TestClass2::TestClass2(int i,int j)
{
    a=i;
    b=j;
}
void TestClass2::printb()
{
    cout<<"a="<<a<<" "<<"b="<<b<<endl;
}
void main()
{
    TestClass1 m(7,9);
    m.printa();
}
第5983题

下面程序的输出结果为()。

#include<iostream.h>
class TestClass
{
public:
    TestClass(){val++;};
    static int val;
};
int TestClass::val=0;
void main()
{
    TestClass cs1;
    cout<<cs1.val<<"";
    TestClass cs2;
    TestClass cs3,cs4;
    cout<<cs2.val<<endl;
}
第5984题

下面程序的运行结果是()。

#include<iostream>
using namespace std;
class TestClass
{
    static int n;
public:
    TestClass()
    {
        n++;
    }
    static int test()
    {
        for(int i=0;i<4;i++)n++;
        return n;
    }
};
int TestClass::n=0;
int main()
{
    cout<<TestClass::test()<<" ";
    TestClass c1,c2;
    cout<<TestClass::test()<<endl;
    return 0;
}
第5985题

下列关于成员函数特征的描述中,错误的是()。

第5986题

有如下程序,执行后的输出结果是()。

#include<iostream>
using namespace std;
class Test{
public:
    Test(){n+=2;}
    ~Test(){n-=3;}
    static int getNum(){return n;}
private:
    static int n;
};
int Test::n=1;
int main()
{
    Test*p=new Test;
    delete p;
    cout<<"n="<<Test::getNum()<<endl;
    return 0;
}

第5987题

假定MyClass为一个类,那么下列的函数说明中,()为该类的析构函数。

第5988题

下列情况中,不会调用拷贝构造函数的是()。

第5989题

类MyClass的定义如下,若要对value赋值,则下面语句正确的是()。

class MyClass
{
public:
    MyClass(){}
    MyClass(int i){value=new int(i);}
    int*value;
};
第5990题

若有如下程序,程序运行后的输出结果是()。

#include<iostream>
using namespace std;
int s=0;
class sample
{
    static int n;
public:
    sample(int i)
    {
        n=i;
    }
    static void add()
    {
        s+=n;
    }
};
int sample::n=0;
int main()
{
    sample a(2),b(5);
    sample::add();
    cout<<s<<endl;
    return 0;
}


第5991题

有如下程序,该程序运行后的输出结果是()。

#include<iostream>
using namespace std;
class sample
{
private:
    int x,y;
public:
    sample(int i,int j)
    {
        x=i;
        y=j;
    }
    void disp()
    {
        cout<<"disp1"<<endl;
    }
    void disp()const
    {
        cout<<"disp2"<<endl;
    }
};
int main()
{
    const sample a(1,2);
    a.disp();
    return 0;
}
第5992题

有如下类的定义,横线处的语句是()。

class TestClass
{
    ______ int x,y;
public:
    TestClass(int a=0,int b=0)
    {
        x=a;
        y=b;
    }
    static void change()
    {
        y=10;
        x=10;
    }
}

第5993题

在函数中,可以用auto、extern、register和static这四个关键字中的一个来说明变量的存储类型,如果不说明存储类型,则默认的存储类型是()。

第5994题

若要把函数void fun()定义为TestClass的友元函数,则应该在类TestClass的定义中加入的语句是()。

第5995题

假定MyClass为一个类,则该类的拷贝构造函数的声明语句为()。

第5996题

关于静态成员的描述中,错误的是()。

第5997题

下列关于构造函数的描述中,错误的是()。

第5998题

下面关于构造函数和析构函数的描述中,错误的是()。

第5999题

下面程序的输出结果是()。

#include<iostream>
#include<math.h>
using namespace std;
class point
{
private:
    double x;
    double y;
public:
    point(double a,double b)
    {
        x=a;
        y=b;
    }
    friend double distances(point a,point b);
};
double distances(point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
    point p1(1,2);
    point p2(5,2);
    cout<<distances(p1,p2)<<endl;
    return 0;
}
第6000题

有以下程序,执行后的输出结果是()。

#include<iostream>
using namespace std;
class R
{
public:
    R(int r1,int r2)
    {
        R1=r1;
        R2=r2;
    }
    void print();
    void print()const;
private:
    int R1,R2;
};
void R::print()
{
    cout<<R1<<","<<R2<<endl;
}
void R::print()const
{
    cout<<R1<<","<<R2<<endl;
}
int main()
{
    R a(5,4);
    const R b(20,52);
    a.print();
    b.print();
    return 0;
}