Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
복소수 클래스 생성하기
/* 실수부와 허수부로 나뉘어있는 '복소수' 클래스를 만들어 본다. 순서쌍 (real, imag) */ #include <iostream> using namespace std; class Complex{ public: Complex(){ real = 0; imag = 0; } Complex( double real_, double imag_){ real = real_; imag = imag_; } public: double GetReal() { return real; } void SetReal(double real_){ real = real_; } double GetImag(){ return imag; } void SetImag(double imag_){ imag = imag_; } private: double real; double imag; }; int main(){ Complex c1; Complex c2 = Complex(2,3); Complex c3(2,3); Complex c4 = {2,3}; Complex c5 = Complex{2,3}; Complex c6{2,3}; cout << " c1 = " << c1.GetReal() << ", " << c1.GetImag() << endl; cout << " c2 = " << c2.GetReal() << ", " << c2.GetImag() << endl; cout << " c3 = " << c3.GetReal() << ", " << c3.GetImag() << endl; cout << " c4 = " << c4.GetReal() << ", " << c4.GetImag() << endl; cout << " c5 = " << c5.GetReal() << ", " << c5.GetImag() << endl; cout << " c6 = " << c6.GetReal() << ", " << c6.GetImag() << endl; }
run
|
edit
|
history
|
help
0
narrow_cast
MSVCStatic
multiplie linked list numbers
C++ standard violation: [templates][explicit instantiation][access checking]
ㅇㅇ
PreprocessorVsNamespace
cross-platform sleep function
WinAPI not accessible
c++ pure apstraction
du