Cpp 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 터를 저장하고 얻어오는 템플릿 클래스 정의하기 IT COOKBOOK 13[예제 13-4] 13_4.cpp 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 #include <iostream> using namespace std; template <typename DATATYPE> class Test{ DATATYPE value; public : Test(DATATYPE v); DATATYPE void SetValue(DATATYPE v); DATATYPE DATATYPE GetValue(); }; template <typename DATATYPE> Test<DATATYPE> <DATATYPE>::Test(DATATYPE v) <DATATYPE> DATATYPE { value = v; } template <typename DATATYPE> void Test<DATATYPE> <DATATYPE>::SetValue(DATATYPE v) <DATATYPE> DATATYPE { value = v; - 11 } [실습하기 13-4] 데이터를 저장하고 얻어오는 템플릿 클래스 정의하기 IT COOKBOOK 13[예제 13-4] 13_4.cpp 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 template <typename DATATYPE> <DATATYPE>::GetValue() DATATYPE Test<DATATYPE> <DATATYPE> { return value; } void main() { Test<int> obj1(10); <int> obj1.SetValue(10); cout<<obj1.GetValue()<<endl; Test<double> obj2(5.7); <double> cout<<obj2.GetValue()<<endl; } - 12 - [실습하기 13-5] 자...
View Full Document

This document was uploaded on 01/19/2014.

Ask a homework question - tutors are online