题目内容

程序填空:设计一个类模板,其中包括数据成员一维动态数组以及在其中进行查找数据元素的成员函数int search(T)。#include using namespace std;______1______class A{private:int size;T* element;public:A(intsz);~A();int Search(T);void SetElement(int index,const T& value);};templateA::A(intsz){ size=sz>1? sz:1; element=new T[size]; }templateA::~A(){ delete [] element; }template______2________){int i;for(i=0;ivoid A::SetElement(int index,const T& value){ element[index]=value; }int main(){____3______; //用int实例化,建立模板类对象intAry,初始长度为5_____4______;//用double实例化,建立模板类对象douAry,初始长度为10for(inti=0;i<5;i++)intAry.SetElement(i,i+3);for(inti=0;i<10;i++)douAry.SetElement(i,(i+i)*0.35);inti=intAry.Search(7);if(i>=0)cout<=0)cout<

查看答案
更多问题

Fill in the blank with the word given below. Change the form where necessary. Each word can be used only once.1.Fortunately, the accident didn't _____ many people, for there was little traffic at that hour.

Fill in the blank with the word given below. Change the form where necessary. Each word can be used only once.2.She______ her ambition of becoming a fashion designer after years of hard work.

Fill in the blank with the word given below. Change the form where necessary. Each word can be used only once.3.They kept on trying their best to develop their business, but in such_____ market competition, they had no idea if success would come along one day.

Fill in the blank with the word given below. Change the form where necessary. Each word can be used only once.4.As music plays an important role in our life, many music teachers and educators______ taking up a musical instrument at a young age.

答案查题题库