已知程序的结果为1 2 3,请填空。 include template class A { public: T X, 已知程序的结果为1 2 3,请填空。include<iostream.h>template<class T>class A{public:T X, y, z;void display( ) {cout < < x < < " " < < y < < " " < < z;}};void main( ){A<int>a1;_______________a1.display( ) ;}
已知程序的结果为1 2 3,请填空。 include template class A { public: T X,
已知程序的结果为1 2 3,请填空。
include<iostream.h>
template<class T>
class A
{
public:
T X, y, z;
void display( ) {cout < < x < < " " < < y < < " " < < z;}
};
void main( )
{
A<int>a1;
_____
_____
_____
a1.display( ) ;
}
相关考题:
下列程序段中,A_class的成员函数Variance()可求出两数的平方差,请改写该程序段,把Variance()函数从A_class类中分离出来,用友元函数来实现该函数的功能。class A_class {private:intx,y,t;public:A_class(int i,int j):x(i),y(j) {if(yx){t=x;x=y;y=t;}}intVariance(){return x*x-y*y;}//其它函数从略};void main() {A_classA_obj(3,5);coutResult:A_obj.Variance()endl;}
阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】设单链表的结点类和链表类的定义如下,链表不带有表头结点。请填空:include<iostream.h>include<assert.h>template<class T>class List;template<class T>class ListNOde{friend (1);private:T data;ListNode<T> *link;public:ListNode():link(NULL)()ListNOde(const T item,ListNOde<T>*next=NULL):data(item),link(next){}};template<class T>class List{private:ListNode<T>*first;void createList(T A[],int n,int i,ListNOde<T>*p);void printList(ListNOde<T>*p);public:List();~List();friend ostream operator<<(ostream ost,List<T>L);friend istream operator>>(istream ist,List<T>L);};template<class T>istream operator>>(istream ist,List<T>1){int i,n; ist>>n;T A[n];for(i=0;i<n;i++) (2);createList(A,n,0,first);}template<class T>void List<T>::createList(TA[],int n,int i,ListNOde<T>* p){//私有函数:递归调用建立单链表if(i==n)p=NULL;else{p=new ListNode<T>(A[i]);assert(p !=NULL);createList((3));}}template<class T>ostream operator<<(ostream ost,List<T> L){(4);}template<class T>void List<T>::printList(ostream ost,ListNode<T>*p){if(p!=NULL){ost<<p->data;(5);}}
下列程序的运行结果为includetemplateclass FF{TT a1,a2,a3;public:FF(T 下列程序的运行结果为 #include<iostream.h> template<class TT> class FF {TT a1,a2,a3; public: FF(TT b1,TT b2,TT b3){a1=b1;a2=b2;a3=b3;} TT Sum(){return a1+a2+a3;}}; void main() { FF<int>x(int(1.1),2,3),y(int(4.2),5,6); cout<<x.Sum()<<‘‘<A.6.1 15.2B.6 15C.6 15.2D.6.1 15
程序的结果为______。include"iostream.h" template T total(T*data) { Ts=0; while( 程序的结果为______。include"iostream.h"template<typename T>T total(T*data){Ts=0;while(*data){S+=*data++;}return S;}int main(){int x[]={2,4,6,8,0,12,14,16,18};cout<<total(x);retum 0;cout<<endl;}
以下程序的运行结果是______。 include include template class TA 以下程序的运行结果是______。include<iostream.h>include<math.h>template<class T>class TAdd//定义类模板TAdd,T为类型{Tx,y;public:TAdd (Ta,Tb) {x=a,y=b;) //构造函数Tadd() { retum x+y;}//成员函数};void main( ){TAdd<int>A (5,6);
以下程序的执行结果是______。 include class base { public: virtual void who(){c 以下程序的执行结果是______。include<iostream.h>class base{public:virtual void who(){cout<<"base class"<<endl:}};class derrvel:public base{public:void who(){cout<<"derivel class"<<endl:}};class derive2;public base{public:void who() {cout<<"derive2 class"<<endl;}};void main(){base obj1,*P;derive1 obj2;derive2 obj3:p=obj1;p->who();p=obj2:p->who();p=obj3;p->who();}
以下程序的执行结果是()。includetemplateclass Sample{ T n;Public: Samp 以下程序的执行结果是( )。 #include<iostream.h> template<class T> class Sample { T n; Public: Sample (T i){n=i;) void operator ++(); void disp() {cout<<"n="<<n<<endl;} }; template<class T> void Sample<T>:: opetatA.n=aB.a=OC.n=bD.a=b
阅读下面程序:include template class TAdd{private:T x, y;public:TAdd(T 阅读下面程序:include <iostream.h>template <class T>class TAdd{private:T x, y;public:TAdd(T a, T b){x=a;y=b;}T add(){return x +y;}};void main( ){TAdd<int>a(5,6);TAdd<double>b(2.4,5.8);cout<<"s1 ="<<A. add()<<",";cout<<"s2="<<B, add()<<end1;}写出该程序的运行结果:【 】。
下列的模板说明中,正确的是()A.template <typename T1, typename T2>B.template <class T1, T2>C.template < T1 class, T2 class >D.template <typename T1; typename T2>