[c++] 프로그래머스 - 모의고사( Level 1)
문제 코딩테스트 연습 - 모의고사 수포자는 수학을 포기한 사람의 준말입니다. 수포자 삼인방은 모의고사에 수학 문제를 전부 찍으려 합니다. 수포자는 1번 문제부터 마지막 문제까지 다음과 같이 찍습니다. 1번 수포자가 찍는 programmers.co.kr 코드 #include #include #include using namespace std; struct info{ vectorcheck_num; int peo_num; int correct_cnt; }; vectorpeo; vectorpeo1={1,2,3,4,5}; vectorpeo2={2,1,2,3,2,4,2,5}; vectorpeo3={3,3,1,1,2,2,4,4,5,5}; bool cmp(info a,info b){ return a.correct_cn..
2021. 10. 21.
[c++] class 에서 멤버 변수를 초기화 하는 세가지 방법
멤버 변수를 초기화하는 방법 세 가지를 알아보자 클래스의 선언부와 구현부를 분리했다고 가정했을 때, 아래와 같이 클래스가 선언되어있다고 가정한다. class Point{ int x,y; public: Point(); Point(int a, int b); }; (1) 생성자 코드에서 멤버 변수 초기화 Point::Point(){ x=1,y=1; } Point::Point(int a,int b){ x=a,y=b; } (2) 생성자 서두에 초깃값으로 초기화 Point::Point():x(1),y(1){} Point::Point(int a, int b):x(a),y(b){} (3) 클래스 선언부 에서 직접 초기화 class Point{ int x=1,y=1; public: Point(); Point(int a,..
2021. 10. 20.