Cpp 056 057 058 059 060 061 062 063 064 065 066 067

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: a=new_A; b=new_B; c=0; } class Add : public Calc{ public : void Sum(); }; void Add::Sum() { c=a+b; } void main() { Add y(3, 5); y.Prn(); } - 19 - [실습하기 11-5] Add 클래스에 생성자 정의하기 11[예제 11-5] 11_5.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; class Calc{ protected: int a; int b; int c; public: void Prn(); Calc(int new_A,int new_B); }; // 기반 클래스에 생성자 추가 void Calc::Prn() { cout<<a<<"\t"<<b<<"\t"<<c<<endl; } Calc::Calc(int new_A,int new_B) // 기반 클래스에 생성자 추가 { a=new_A; b=new_B; c=0; } - 20 - IT COOKBOOK [실습하...
View Full Document

Ask a homework question - tutors are online