카테고리 없음 범범조조 2016. 4. 19. 21:12
-상수화 멤버 //Student.h#pragma once #include #include using namespace std; class Student{ const int num; //비 정적 상수화 멤버 필드 string name; int hp; static const int max_hp; //정적 장수화 멤버 필드public: Student(int _num, string _name); void View()const; //상수화 멤버 메소드}; //Student.cpp#include "Student.h" const int Student::max_hp = 200; //정적 상수화 멤버 필드 초기값 지정Student::Student(int _num, string _name):num(_num) //비 정적 ..
더 읽기
C++/설명 범범조조 2016. 4. 19. 21:10
-생성자와 소멸자 //Student.h#pragma once#include #include using namespace std; class Student{ int num; string name;public: Student(void); Student(int num); Student(int num, string name); void View();}; //Student.h#include "Student.h" Student::Student(void){ num = 0; name = "";} Student::Student(int _num){ num = _num; name = "";} Student::Student(int _num, string _name){ num = _num; name = _name;} void ..
C++/설명 범범조조 2016. 4. 19. 21:09
-접근 지정자//Student.h#pragma once#include using namespace std; #define DEF_IQ 100 //디폴트 IQ#define MAX_IQ 300 //최대 IQ class Student{ int num; string name; int iq; public: Student(int _num, string _name); void Study(int hour); void View();}; //Student.cpp#include "Student.h"#include using namespace std; Student::Student(int _num, string _name){ num = _num; name = _name; iq = DEF_IQ;} void Student::St..
C++/설명 범범조조 2016. 4. 19. 21:07
-정적 클래스//정적 클래스#include using namespace std; #define GC GameConst #define GC_MAXHP GC::max_hpclass GameConst{public: static const int max_hp; static const int min_hp; static const int max_iq; static const int min_iq;private: GameConst(); //생성자의 접근 가시성을 private으로 지정}; const int GameConst::max_hp = 200;const int GameConst::min_hp = 0;const int GameConst::max_iq = 300;const int GameConst::min_iq = ..
C++/설명 범범조조 2016. 4. 19. 21:06
-정적멤버 static //Student.h#pragma once#include class Student{ int num; static int last_num; //정적 멤버 필드public: Student(void); int GetNum(); static int GetLastNum(); //정적 멤버 메소드}; //Student.cpp#include "Student.h"int Student::last_num; //static 멤버 필드는 멤버 필드선언을 해야함. 선언문에서는 static 키워드 사용 안 함 Student::Student(void){ last_num++; num = last_num;} int Student::GetNum(){ return num;} int Student::GetLastNu..
C++/설명 범범조조 2016. 4. 19. 21:03
-특별한 멤버 this//this 는 있는 멤버이고 정적인 멤버입니다.//::스코프 연산자#include using namespace std; int num = 1; class Demo{ int num;public: Demo(int num) { this->num = num; } void View(int num)const { cout
-캡슐화 개요 #include #include using namespace std; class Unit //class 대신 struct 써도 오류는 안난다. 접근 지정을 최소하 하자!!!!!!!!!!!{ //클래스의 디폴트 가시성은 private //구조체의 디폴트 가시성은 public int num; string name; int hp;public://클래스 외부에서도 접근 가능할 수 있게 접근 지정사 설정 Unit(int _num, string _name) { num = _num; name = _name; hp = 100; } void Train(int hour)//멤버 메서드 { cout> n; int *darr = new int[n]; //배열 스러운거지 배열 생성자 아니다. for(int i =..
C++/설명 범범조조 2016. 4. 19. 20:59
//string 형식 개요#include #include using namespace std; int main(void){ string s = "hello"; string s2 = "hello"; string s3; if(s == s2) { cout
C언어 범범조조 2016. 4. 17. 23:32
이번에 올리는 코드는 C언어 장르별 도서관리 프로그램 소스코드 입니다.앞에서 올린 도서관리 프로그램 예관탄에서 각각의 함수의 기능들을 추가해서 함수 내부의 코드들을 완성시켰고 또한 거기에 도서 장르를 추가해 장르별 도서관리 프로그램을 완성시켰습니다. 연습하는겸 해서 한번씩 따라 쳐 보시면 프로그램의 흐름을 이해하기 쉬울겁니다.^^===================================================================//App.h#pragma oncevoid Start_App();=================================================================== //App.c#include "Genre.h"#include "EHArr.h..
C언어 범범조조 2016. 4. 17. 22:46
C언어 도서관리 프로그램에 쓰이는 함수들과 헤더파일 예광탄들을 하나씩 올리도록 하겠습니다!이 함수들과 헤더파일들을 따라 쳐 보시면 도서관리 프로그램에 필요한 기본 틀이 완성이 됩니다.완성본 코드는 이 다음장에 올리도록 하겠습니다. C언어 도서관리 프로그램 예광탄//App.h#pragma oncevoid Start_App();===================================================================//App.c#include "App.h"#include "ehcommon.h"typedef struct App App;struct App{ int reserved;}; App *New_App();void Delete_App(App *app);void App_Init..
C언어 범범조조 2016. 4. 17. 22:06
============================================================================================실습 시나리오 학생은 학번, 이름, 체력, 지력, 스트레스, 연속으로 공부한 횟수를 멤버로 갖는다. 학번은 순차적으로 부여하며 이름은 생성할 때 입력인자로 전달받는다. 체력은 초기값이 100이며 0에서 100 사이의 값을 유지한다. 지력은 초기값이 100이며 0에서 200 사이의 값을 유지한다. 스트레스는 초기값이 0이며 0에서 100 사이의 값을 유지한다. 연속으로 공부한 횟수는 초기값이 0이며 0에서 5 사이의 값을 유지한다. 학생이 공부하면 연속으로 공부한 횟수는 1 증가하며 그 외의 행동을 하면 0으로 리셋한다. 학생이 공부하면 체력이..
C언어 범범조조 2016. 4. 17. 22:05
=================================================================================문자열의 길이 구하는 프로그램 #include #define size 255 int main(void){char _in[size];char _search[size];char *p;char *q;int i = 0;int count1 = 0;int count2 = 0;int count3 = 0;int pos = 0; printf("문자열 _in을 입력하세요 :\n");scanf_s("%s",_in,sizeof(_in)); p = _in;count1 = 0;for(i = 0 ; i < size; i++){if( *(p+i) == NULL){break;}count1++..