C++程序设计
历年真题
C++类成员的访问权限有______、公有和保护三种。
写出声明一个复数对象num的语句,并使对象被初始化为单精度2.2+1.3i,此声明语句是______。
#include<iostream.h> class testl{ private:Int x; public:testl ( ) {x=2;} void set (int a) { x=a;} void get ( ) { cout << x << endl;} }; class test2{ private:int x; public:test2( ) { x=3;} void set ( int a ) { x=a;} void get ( ) { cout << x << endl;} }; class test:public testl,public test2.{ private:int x; public:void set(int a){x=a;} void gettest ( ) { cout << x << endl ;} } ; main ( ) { test a;a.get( ); }
#include < iostream > using namespace std ;class basw{private : int x ;pucllic : base ( int a ) { x = a ; }int get ( ) { return x ; }void showbase( ) {cout << "x=" << x << endl ; }};class Derived : public base { private : int y ;public : Derived ( int a , int b ) ; base ( a ) { y = b ; }void showderived ( ){ cout << "x=" << get ( ) << " , y= " << y << endl ; }};void main ( ){base b ( 3 ) ;Derivd d (6 , 7) ;b . showbase ( ) ;d . showderived ( ) ; _____________________________ ;b. showbase ( ) ;_____________________________ ;b1 . showbase ( ) ;}输出结果如下: x=3 x=6,y=7 x=6 x=6 x=6 x=6,y=7 x=6
一个函数的功能不太复杂,但要求被频繁调用,选用最适合的是( )。
假定有类AB,有相应的构造函数定义,能正确执行"AB a(4),b(5),c[3],*p[2]={&a,&b};"语句,请问执行完此语句后共调用该类析构函数的次数为( )。
在下面有关析构函数特征的描述中,正确的是( )。
派生类的对象对它的哪一类基类成员是可以访问的?( )
如果A是抽象类,则下面正确的是( )。
下列关于纯虚函数与抽象类的描述中,错误的是( )。
«
1
2
...
22
23
24
25
26
27
28
...
92
93
»