Praktikum S data 1

#include <cstdlib>
#include <iostream>

using namespace std;

template <class T>
class contoh{
public:
T max(T, T) ;
};
template <class T>
T contoh<T>::max(T a, T b){
return a > b ? a : b ;
}

int main(int argc, char *argv[])
{
contoh<char> *Contoh=new contoh<char>;
cout<<“Nilai max(a,b) : “<<Contoh->max(‘a’,’b’)<<endl;
contoh<double> *sampel=new contoh<double>;
cout<<“Nilai max(3.5,5.3) : “<<sampel->max(3.5,5.3)<<endl;
contoh<int> *Sample=new contoh<int>;
cout<<“Nilai max(45,55) : “<<Sample->max(45,55)<<endl;
system(“PAUSE”);
return EXIT_SUCCESS;
}

 

Tinggalkan Balasan

Please log in using one of these methods to post your comment:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s