OJ嘻唰唰之類模板(1)類模板 求陣列的最大值

2021-07-03 16:18:04 字數 1323 閱讀 8580

問題及**:

/**檔名稱:test.cpp

*完成日期:2023年7月7日

*版本號:v1.0

**問題描述:類模板---求陣列的最大值

找出乙個陣列中的元素的最大值,陣列大小為10。(用類模板來實現)

陣列元素型別作為類模板的引數。

在下面的程式段基礎上完成設計,只提交begin到end部分的**

#include #include using namespace std;

template class array_max //宣告類模板 ;

//將程式需要的其他成份寫下來,只提交begin到end部分的**

//******************** begin ********************

______(1)_______

void array_max::set_value( )

______(3)________

t array_max::max_value( )

//********************* end ********************

int main( )

;//將程式需要的其他成份寫下來,只提交begin到end部分的**

//******************** begin ********************

template void array_max::set_value( )

template t array_max::max_value( )

return max;

}//********************* end ********************

int main( )

{ array_maxarrmax_int; //定義物件arrmax_int,該物件中陣列元素型別為整型

arrmax_int.set_value( ); //呼叫arrmax_int的set_value函式,向陣列元素輸入數值

coutarrmax_double.set_value( ); //呼叫arrmax_double的set_value函式,向陣列元素輸入數值

coutarrmax_char.set_value( ); //呼叫arrmax_char的set_value函式,向陣列元素輸入數值

coutarrmax_string.set_value( ); //呼叫arrmax_string的set_value函式,向陣列元素輸入數值

cout《知識點總結:關於類模板的一些用法和概念

學習心得:舉一反三

OJ 嘻唰唰抽象基類

編寫乙個程式,宣告抽象基類shape,由它派生出3個派生類 circle 圓形 rectangle 矩形 三角形 用乙個函式printarea分別輸出以上三者的面積 結果保留兩位小數 3個圖形的資料在定義物件時給定。圓的半徑 矩形的邊長 三角形的底與高 圓的面積 矩形的面積 三角形的面積 12.6 ...

OJ嘻唰唰 學生資訊的輸入與輸出

time limit 1 sec memory limit 128 mb submit 164 solved 91 submit status web board 閱讀並修改以下程式,實現學生資訊的輸入和輸出。include include include using namespace std c...

oj類模板

問題 宣告乙個類模板,利用它分別實現兩個整數 浮點數和字元的比較,求出大數和小數。說明 在類模板外定義各成員函式。程式 include include using namespace std templateclass compare template 還都要寫一遍 compare compare ...