반응형

C++ 104

[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

[C++ 소스] 학생 클래스 (== 연산자 중복정의, 클래스 내부에 정의)

[C++ 소스] 학생 클래스 (== 연산자 중복정의, 클래스 내부에 정의) //Student.h#pragma once#include #include using namespace std;class Student{ string name; const int num;public: Student(int num,string name); bool IsEqual(int num)const; void View()const; bool operator==(int num)const;}; bool operator == (int num, const Student &stu); //Student.cpp #include "Student.h" Student::Student(int num,string name):num(num) { this..

C++/디딤돌 C++ 2016.12.14

[C++ 소스] 학생 클래스 (== 연산자 중복정의, 교환법칙 적용)

[C++ 소스] 학생 클래스 (== 연산자 중복정의, 교환법칙 적용) //Student.h#pragma once#include #include using namespace std;class Student{ string name; const int num;public: Student(int num,string name); bool IsEqual(int num)const; void View()const;}; bool operator == (const Student &stu, int num); bool operator == (int num, const Student &stu); //Student.cpp#include "Student.h"Student::Student(int num,string name):num..

C++/디딤돌 C++ 2016.12.14

[C++ 소스] 학생 클래스 (== 연산자 중복정의)

[C++ 소스] 학생 클래스 (== 연산자 중복정의) //Student.h#pragma once#include #include using namespace std;class Student{ string name; const int num;public: Student(int num,string name); bool IsEqual(int num)const; void View()const;}; bool operator == (const Student &stu, int num); //Student.cpp#include "Student.h"Student::Student(int num,string name):num(num){ this->name = name;}bool Student::IsEqual(int num)c..

C++/디딤돌 C++ 2016.12.14

[C++ 소스] 학생 클래스 (연산자 중복정의 하기 전)

[C++ 소스] 학생 클래스 (연산자 중복정의 하기 전) //Student.h#pragma once#include #include using namespace std;class Student{ string name; const int num;public: Student(int num,string name); bool IsEqual(int num)const; void View()const; }; //Student.cpp#include "Student.h"Student::Student(int num,string name):num(num){ this->name = name;}bool Student::IsEqual(int num)const{ return this->num == num;}void Student::..

C++/디딤돌 C++ 2016.12.14

크루스칼(Kruscal) 알고리즘, 최소신장 트리, 탐욕(Greedy) 알고리즘 [C++ 소스]

크루스칼(Kruscal) 알고리즘, 최소신장 트리탐욕(Greedy) 알고리즘 [C++ 소스] "본문 내용"은 언제나 휴일 본 사이트에 있습니다. //Edge.h#pragma once#include using namespace std;class Edge{ string vt1; string vt2; int weight;public: Edge(string vt1,string vt2,int height); bool Exist(string vt)const; bool Exist(string vt1, string vt2)const; string Other(string vt)const; void View()const; int GetWeight()const; string GetVt1()const; string GetVt..

프림(Prim) 알고리즘, 최소신장 트리, 탐욕(Greedy) 알고리즘 [C++ 소스]

프림(Prim) 알고리즘, 최소신장 트리탐욕(Greedy) 알고리즘 [C++ 소스] "본문 내용"은 언제나 휴일 본 사이트에 있습니다. //Edge.h#pragma once#include using namespace std;class Edge{ string vt1; string vt2; int weight;public: Edge(string vt1,string vt2,int height); bool Exist(string vt)const; bool Exist(string vt1, string vt2)const; string Other(string vt)const; void View()const; int GetWeight()const; string GetVt1()const; string GetVt2()co..

반응형