Showcomplex cout y yshowcomplex cout

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: [예제 9-2] 9_2.cpp 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 Complex::Complex(int real, int image) { this->real=real; this->image=image; } void Complex::ShowComplex() const { cout<<"( "<< this->real <<" + "<< this->image <<"i )"<<endl ; } void main() { Complex x(10,20); x.ShowComplex(); } - 16 - IT COOKBOOK [실습하기 9-3] 객체 단위로 값 치환하기 [예제 9-3] 9_3.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 Complex { private : int real; int image; public : Complex( int r=0, int i=0); void ShowComplex() const; void SetComplex(int r=0, int i=0); }; Complex::Complex(int r, int i) { real=r; image=i; } void Complex::ShowComplex() const { cout<<"( " <<real <<" + " <<image << "i )" <<endl ; } - 17 - IT COOKBOOK [실습하기 9-3] 객체 단위로 값 치환하기 [예제 9-3] 9_3.cpp 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 void Complex::SetComplex(int r, int i) { real=r; image=i; } void main() { Complex x(10,20); Complex y; cout<<" x => " ; x.ShowComplex(); cout<<" y => "...
View Full Document

This document was uploaded on 01/19/2014.

Ask a homework question - tutors are online