排序
C++遗传问题7
#include<iostream> using namespace std; class Base { public : void show() { cout<< ' In Base ' ; } }; class Derived: public Base { public : int x; void show() { cout<...
C++构造函数问题17
#include<iostream> using namespace std; class Test { public : Test(Test &t) { } Test() { } }; Test fun() { cout << 'fun() Called' ; Test t; return t; ...
C++静态关键字问题5
#include<iostream> using namespace std; class Test { private : static int count; public : Test& fun(); }; int Test::count = 0; Test& Test::fun() { Test::count++; cout...
C++遗传问题4
#include<iostream> using namespace std; class P { public : void print() { cout << ' Inside P' ; } }; class Q : public P { public : void print() { cout << ' Insi...
C++遗传问题3
假设一个整数需要4个字节,并且在下面的类中没有对齐,预测输出。 #include<iostream> using namespace std; class base { int arr[10]; }; class b1: public base { }; class b2: public...
C++运算符重载问题10
下列哪些运算符函数不能是全局的,即必须是成员函数。 (A) 刚出现的 (B) 删去 (C) 转换运算符 (D) 所有这些 答复: (C) 说明: new和delete可以是全局的,参见下面的示例。 #include #...
C++运算符重载问题9
#include<iostream> using namespace std; class Point { private : int x, y; public : Point() : x(0), y(0) { } Point& operator()( int dx, int dy); void show() {cout <<...
C++运算符重载问题10
预测产量? #include<stdlib.h> #include<stdio.h> #include<iostream> using namespace std; class Test { int x; public : void * operator new ( size_t size); void oper...
C++运算符重载问题7
以下程序的输出? #include <iostream> using namespace std; class Test2 { int y; }; class Test { int x; Test2 t2; public : operator Test2 () { return t2; } operator int () { ...
C++运算符重载问题6
预测产量 #include<iostream> using namespace std; class A { int i; public : A( int ii = 0) : i(ii) {} void show() { cout << i << endl; } }; class B { int x; pu...
C++构造函数问题16
预测以下程序的输出? #include <iostream> using namespace std; class Test { private : int x; public : Test( int i) { x = i; cout << 'Called' << endl; } }; int main...
C++运算符重载问题4
以下哪一个操作符应该优先作为全局函数而不是成员方法重载? (A) 后缀++ (B) 比较运算符 (C) 插入运算符<< (D) 前缀++ 答复: (C) 说明: cout是编译器定义的类ostream类的对象...