49.下面程序给出了一个从普通的基类派生出一个模板类的方法,在答题纸上填上缺少的
部分。
#include <iostream>
using namespace std;
class Base
{
public:
Base(int a){x=a;}
int Getx(){return x;
void showb(){cout<<x<<endl;}
private:
int x;
};
template <class T>
class derived: public Base
{
public:
derived(T a,int b):____
{y=a;}
T Gety( ){return y;}
void showd( ){cout<<y<<" "<<Gets ( )<< endl;}
private:
} ;
void main ( )
{ Base A(458);
A.showb ( );
derived < char * >B ("It is" ,1357);
B.showd ( );
}
50.下面程序的运行结果如下:
20,22
60,22
在答题纸上填上缺少的部分。源程序如下:
#include < iostream >
using namespace std;
class base
{
private:
const int a;
static const int b;
public:
base( int);
void Show();
};
=22;
: a (i){ } //初始化
void base : :Show( )
{cout<<a<<","<<b<<endl;}
void main ( )
{
base al (20) ,a2 (60);
al. Show ( );
a2. Show ( );
}