C++/설명 범범조조 2018. 8. 6. 17:43
콜백(CALLBACK) 함수란? 이번 포스팅에서는 콜백(CALLBACK)함수에 대하여 알아 보도록 하겠습니다. C#을 다루는 사람들이면 Delegate 문법을 익히면서 콜백(CALLBACK)에 대해서 분명히 들어 보셨을 거라고 생각합니다. 저 또한 마찬가지구요..^^ 그렇다면 콜백(CALLBACK)함수가 도대체 무엇이냐???? 우선 콜백(CALLBACK)함수의 정의를 알기 전에 콜(CALL)에 대한 개념을 먼저 익히도록 하겠습니다. CALL이란? 호출자(사용자)가 피호출자(시스템 or 응용프로그램)에게 어떠한 서비스 또는 이벤트를 호출하는 것을 의미합니다. 콜백(CALLBACK) 함수는 콜(CALL)의 개념과는 반대의 개념을 가지고 있습니다. CALLBACK 함수란? 피호출자(시스템 or 응용프로그램)가..
더 읽기
C++/설명 범범조조 2018. 8. 6. 10:56
[C++] strcat_s 함수를 사용하여 문자열 결합하기 이번 포스팅에서는 C++환경에서 문자열을 결합하는 방법에 대해서 알아보도록 하겠습니다. 실제 실무에서 파일을 쓸 때, 또는 문자를 이용하여 어떠한 작업을 할 때 많이들 사용하는 방법이기 때문에 C++언어를 이용하여 사용법을 익히게 되면 유용하게 사용할 수 있거라 생각합니다.^^ C++에서 문자열을 결합하기 위해서는 strcat_s 함수를 이용하여 결합을 시켜줘야 합니다. strcat_s 함수 원형 char *strcat_s(char *dest, const char *src, size_t count); strcat_s 함수 사용 방법
C++/설명 범범조조 2016. 4. 20. 12:39
-상속과 다형성 최종 실습(학생 프로그램)//Student.h#pragma once#include #include using namespace std; class Student { string name; //학생 이름 const int number; //학생 주민번호 static int last_number; //학생 주민번호 순차 int hp; int iq; int stress; int scnt; static const int Def_Hp; static const int Max_Hp; static const int Min_Hp; static const int Def_Iq; static const int Max_Iq; static const int Min_Iq; static const int Def_St..
C++/설명 범범조조 2016. 4. 20. 12:36
-상속과 다형성 실습2(상품, 할인상품)시나리오1. 상품상품 이름과 가격을 멤버 필드로 갖습니다.생성할 때 이름과 가격을 입력 인자로 받습니다.가격과 이름의 접근자를 제공하며 가격 접근자는 가상 메서드 입니다.상품 정보를 출력하는 가상 메서드를 제공합니다.형식 내부에서만 접근 가능한 가격 설정자와 이름 절정자가 있습니다. 2. 할인상품할인율을 멤버 필드로 갖습니다.상품 이름과 가격, 할인율을 입력 인자로 받습니다.가격 접근자와 상품 정보 출력하는 메소드를 재정의 합니다.할인율의 접근자 메서드를 제공합니다.형식 내부에서만 접근할 수 있는 할인율 설정자가 있습니다. //DiscountProduct.h#pragma once#include "Product.h" class DiscountProduct :publi..
C++/설명 범범조조 2016. 4. 20. 12:33
-상속과 다형성 실습 1. 도형 //Diagram.h#pragma once#include #include using namespace std; class Diagram{ const int id; static int last_id;public: Diagram(); virtual void Draw() = 0;protected: int GetID()const;}; //Diagram.cpp#include "Diagram.h" Diagram::Diagram():id(last_id++){}void Diagram::Draw(){}int Diagram::GetID()const{ return id;} //Line.h#pragma once#include "Diagram.h"#include "POint.h" class Li..
C++/설명 범범조조 2016. 4. 19. 21:28
-파생 개체의 생성과 소멸 과정//상속 개요#include #include using namespace std; class Musician{ string name; //멤버 필드는 무조건 privatepublic: Musician(string name) { this->name = name; coutPlay(); pianist->View(); pianist->Turning(); delete pianist; return 0;}
C++/설명 범범조조 2016. 4. 19. 21:27
-추상 클래스#include #include using namespace std; class Musician{ string name;public: Musician(string name) { this->name = name; } virtual void Play() = 0; //순수 가상 메소드(추상 클래스)(기능 구현을위한 약속 메소드) void Introduce() { coutIntroduce(); musician->Play();} void StartConcert(Musician &musician){ musician.Introduce(); musician.Play();}
C++/설명 범범조조 2016. 4. 19. 21:26
-인터 페이스#include #include using namespace std; #define interface structinterface IPlay{ virtual void Play() = 0;}; //#define interface class //class를 이용하여 인터페이스를 만듬//interface IPlay//{//public:// virtual void Play() = 0;//} class Man:public IPlay{ string name;public: Man(string name) { this->name = name; } virtual void Play() { cout
-하향 캐스팅#include #include using namespace std; class Musician{ string name;public: Musician(string name) { this->name = name; } virtual void Play() = 0; //순수 가상 메소드(추상 클래스)(기능 구현을위한 약속 메소드) void Introduce() { coutIntroduce(); //실행 시간에 musician이 Pianist인지 확인하여 하향 캐스팅 //만약 피아니스트가 아니면 캐스팅 실패하고 0을 반환함 //Pianist *pianist = (*Pianist)musician; //CPP에서는 강제 형변환을 사용하지 마세요 Pianist *pianist = dynamic_cast(m..
C++/설명 범범조조 2016. 4. 19. 21:25
-무효화//무효화#include #include using namespace std; class Programmer{public: void Programming() { coutProgramming(2); Programmer *pro = ehp; pro->Programming(); pro->Programming(3); delete ehp; return 0;}
C++/설명 범범조조 2016. 4. 19. 21:24
-형식의 다형성#include #include using namespace std; class Musician{ string name;public: Musician(string name) { this->name = name; } void Play() { coutPlay();} void StartConcert(Musician &musician){ musician.Play();}
-메소드의 다형성 #include #include using namespace std; class Musician{ string name;public: Musician(string name) { this->name = name; } virtual void Play() { coutIntroduce(); musician->Play();} void StartConcert(Musician &musician){ musician.Introduce(); musician.Play();}