Cpp 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

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: namespace std; class Calc{ protected : int a; int b; int c; public : void Init(int new_A,int new_B); void Prn(); }; void Calc::Init(int new_A,int new_B) { a=new_A; b=new_B; c=0; } void Calc::Prn() { cout<<a<<"\t"<<b<<"\t"<<c<<endl; } class Add : public Calc{ public : void Sum(); }; -9- IT COOKBOOK [실습하기 11-1] 기반 클래스와 파생 클래스 설게하기 11[예제 11-1] 11_1.cpp 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 void Add::Sum() { c=a+b; } class Mul : public Calc{ public: void Gob(); }; void Mul::Gob() { c=a*b; } void main() { Add x; x.Init(3, 5); Mul y; y.Init(2, 7); x.Sum(); x.Prn(); y.Gob(); y.Prn(); } - 10 - IT COOKBOOK 2) 상속관계에서...
View Full Document

This document was uploaded on 01/19/2014.

Ask a homework question - tutors are online