반응형

2016/12/15 4

[C++ 소스] 성적 클래스 (묵시적 형 변환 연산자 중복 정의)

[C++ 소스] 성적 클래스 (묵시적 형 변환 연산자 중복 정의) DCArray.cpp DCArray.h Program.cpp //Score.h#pragma once#include using namespace std;class Score{ int value; public: static const int max_score; static const int min_score; static const int not_score; Score(int value); operator int();private: void SetValue(int value);//값 설정자 }; //Score.cpp#include "Score.h"const int Score::max_score=100;const int Score::min_sc..

C++/디딤돌 C++ 2016.12.15

[C++ 소스] 동적 배열 클래스 (인덱스 연산자 중복 정의)

[C++ 소스] 동적 배열 클래스 (인덱스 연산자 중복 정의) //DCArray#pragma onceclass DCArray{ int *base; int bcapacity; int usage;public: DCArray(int usage=0,int data=0); DCArray(const DCArray &src);//복사 생성자 ~DCArray();//소멸자 void Copy(const DCArray &src);//src 개체를 복사 DCArray &operator=(const DCArray &src);//= 연산자 중복 정의 int &operator[](int index);//인덱스 연산자 중복 정의 bool IsAvailIndex(int index)const;private: void Init(); }..

C++/디딤돌 C++ 2016.12.15

[C++ 소스] 동적 배열 클래스 (대입 연산자 중복 정의)

[C++ 소스] 동적 배열 클래스 (대입 연산자 중복 정의) //DCArray.h#pragma once class DCArray{ int *base; int bcapacity; int usage;public: DCArray(int _capa=0); DCArray(const DCArray &src);//복사 생성자 ~DCArray();//소멸자 void Copy(const DCArray &src);//src 개체를 복사 DCArray &operator=(const DCArray &src);//= 연산자 중복 정의 void PushBack(int data);//순차 보관 void List();//목록 출력private: void Init(); }; //DCArray.cpp#include "DCArray.h"..

C++/디딤돌 C++ 2016.12.15

[C++ 소스] 성적 클래스 (증감 연산자 중복 정의)

[C++ 소스] 성적 클래스 (증감 연산자 중복 정의) //Score.h#pragma once#include using namespace std;class Score{ int value; public: static const int max_score; static const int min_score; static const int not_score; Score(int value); int GetValue()const; //값 접근자 void Increment();//값 1 증가 void Decrement();//값 1 감소 Score &operator++(); //전위 ++ 연산자 중복 정의 const Score operator++(int); //후위 ++ 연산자 중복 정의 Score &operator-..

C++/디딤돌 C++ 2016.12.15
반응형