Getdataendl double b34 datadouble double obj215

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: 를 복사하는 일반 클래스 설계하기 13[예제 13-5] 13_5.cpp 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 #include <iostream> using namespace std; class Data{ private : int value; public : Data(int v); void CopyData(int & v); int GetData(); }; Data::Data(int v) { value = v; } void Data::CopyData(int & v) { value = v; } - 13 - IT COOKBOOK [실습하기 13-5] 자료를 복사하는 일반 클래스 설계하기 13[예제 13-5] 13_5.cpp 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 int Data::GetData() { return value; } void main() { int a=10; Data obj1(10); cout<<obj1.GetData()<<endl; obj1.CopyData(a); cout<<obj1.GetData()<<endl; double b=3.4; /* Data obj2(1.5); cout<<obj2.GetData()<<endl; obj2.CopyData(b); cout<<obj2.GetData()<<endl; */ } - 14 - IT COOKBOOK [실습하기 13-6] 두 개의 자료형에 대해 템플리화하기 13[예제 13-6] 13_6.cpp 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #include <iostream> using namespace std; //Data<TYPE, ARG_TYPE> template <typename TYPE, typename ARG_TYPE> class Data{ TYPE value; public : Data(TYPE v); void CopyData(ARG_TYPE v)...
View Full Document

This document was uploaded on 01/19/2014.

Ask a homework question - tutors are online