C++ 10

10.3

std::set    > 내부적으로 정렬된 상태를 유지     > 비교 연산(, == 등)이 가능 해야함 std::ostream& operatorstd::ostream& > 출력 스트림(std::cout)을 반환Todo 객체를 받음 std::cout  1. o == std::cout        > [중요도: X] Y2. std::cout  주의!bool operator t.priority;}  A==B 와 같은 식으로 할시if) A==B 라고 하면       : A>B : false , A       : A==B 이므로 같다고 처리함  > A(1, "안녕"), B(1,"잘가") > 서로 다름에도 불구  알고리즘 라이브러리 서술자 (Predicate): 특정한 조건    > bool 을 리턴하는 함수객체..

C++/모두의코드 2025.03.03

10장

++ 표준 템플릿 라이브러리 (Standard Template Library - STL) container : 임의 타입 객체 저장iterator     : 컨테이너의 원소 접근 algorithm : 원소들로 수행 //  Big O 표현법 : 최고 차항만 표기//    > O (N^2) // 성능 구린편 container1. sequence 1) vector : 순차적 > 원소 접근 빠름     :: O(1) , 원소 개수보다 많은공간 할당                          중간에 추가/제거 :: O(n) , 하나하나씩 해야함2) list3) deque   반복자   리스트 : 양방향 연결구조           : O(1) 로 매우 빠른편 한칸씩만 이동가능              > itr..

C++/모두의코드 2025.02.18

9장

1.  template template  원하는 타입을 넣어주면 알아서 변형>Vector int_vec;Vector :  활용 2. C++ 기본처리단위 : 1byte bool : 1bit>Vector 따로 처리>>템플릿 특수화 (template specialization)template class Vectordata(new unsigned int[n / 32 + 1]), capacity(n / 32 + 1), length(0) int 형으로 생성한 공간에 bool 로 채우면4byte = 32bit 즉, 32개의 bool 3.bool operator[](int i) { return (data[i / 32] & (1   비트 and 연산 후 0이 아니라면 return 1                  "  ..

C++/모두의코드 2025.02.12

8-1 장

Cell*** data_table;Table::Table(int max_row_size, int max_col_size) : max_row_size(max_row_size), max_col_size(max_col_size) { data_table = new Cell**[max_row_size]; for (int i = 0; i     1. data_table 이라는 3중 포인터     2. data_table = new Cell**[max_row_size]; // Cell* 들을 저장하는 배열 // 각 배열의 시작주소들을 저장      > data_table 은 Cell** 타입     > max_row_size 만큼의 row(열) 배열생성3. for (int i = 0; i   > 한 개의 ..

C++/모두의코드 2025.02.09

7장

C++ 입출력 라이브러리 while (std::cin >> t) {// int t t 의 타입이 아니면 // int 형이 아니면fail bit  ON > bool false> std::cin.clear(); // 플래그들을 초기화 하고 std::cin.ignore(100, '\n'); // 개행문자가 나올 때 까지 무시한다ios 객체에서 버퍼 처리함 ( 사용자 입력 > 버퍼 > 컴파일)  > 플래그에 맞춰 실행>>1. 플래그 초기화2. 버퍼 무시( 첫번째에는 최대 100개, 두번째로 '\n' 이 나오면 삭제)    > aaaaaaaa~~~       aaaaaaaa~~~       aaa    > 버퍼 3개 삭제 출력 진법 변경std::cin.setf(ios_bas..

C++/모두의코드 2025.02.04

6장

Employee **employee_list;  단일 포인터 vs 이중포인터    : 값을 넣느냐, 주소를 넣느냐..Employee **list = (Employee **)malloc(n * sizeof(Employee *));// 이걸로 일단 공간을 만들고list[0] = (Employee *)malloc(sizeof(Employee));list[1] = (Employee *)malloc(sizeof(Employee));// 이렇게 값을 개별적 malloc 공간으로 넣을 수 있음// 나중에 추가하고 싶으면n = 4;list = (Employee **)realloc(list, n * sizeof(Employee *));// 공간을 다시 만들어주고 list[2] = (Employee *)malloc(..

C++/모두의코드 2025.02.02

5장 // 5.3 뒷부분은 복습때

Overloading : 연산자들을 직접 정의 하는것(리턴 타입) operator(연산자) (연산자가 받는 인자) 조심)Complex& operator+(const Complex& c) { real += c.real; img += c.img; return *this;}>Complex a = b + c + b; (b.plus(c)).plus(b)> 1. b.plus(c) == b+c 가 b의 값으로 들어감 (reference)> 2. (b+c)+(b+c) 가 되어 다른 값이 나옴 friend 키워드// B 는 A 의 친구!friend class B;// func 은 A 의 친구!friend void func();클래스 B와  func() 함수는 class A의 모든 변수와함수 접근가능짝사랑.. 이항연..

C++/모두의코드 2025.02.01

4장 이어서..

1. 레퍼런스함수의 리턴 > 레퍼런스     int& ref();>    int& rev = ref(); ref() = 3;     >> 레퍼런스로 값 복사 or 레퍼런스처럼 값지정 2.marine2.be_attacked(marine1.attack()).be_attacked(marine1.attack());  1.  marine2.be_attacked(marine1.attack())  > return *this  2. marine2.be_attacked(marine1.attack())   > 앞에 거 하고 리턴 > 뒤에거 Marine& ~~~(){    return *this;}// 기존의 Marine을 가져옴 Marine ~~~() {  return *this;}// 새로운 Marine을 생성해서 그걸..

C++/모두의코드 2025.01.31

3장, 4장

malloc , freenew , delete new  :Type* name = new Type;배열 : new Type[size]; delete :   delete name;배열 : delete[] name; // size 안넣어줘도됨 객체 : 변수들, 참고 자료들로 이루어진 소프트웨어 덩어리   내가 함수속에 들어가는것이 아닌  > 절차지향 (procedure :: 각 함수 들을 걸쳐감)내가 함수를 실행한다.                   > 객체지향 (object       :: 각 객체가 함수를 실행) private :   객체가 함수를 통해 변수를 변경한다.      > 객체외의 존재 (프로그래머 포함 + instance)는 접근할수없다 public :  객체 외에서 (instance에서도) ..

C++/모두의코드 2025.01.30

1장

#include int main() { std::cout iostream :  Input Output stream ~= stdio    std : 이름 공간(namespace)  :: 표준 라이브러리의 (iostream) 모든 함수, 객체 등 정의 나만의 namespace 를 만들자 "header1.h"namespace header1 {int foo();void bar();} header1 namespace 에는 함수2개 정의#include "header1.h"#include "header2.h"namespace header1 {int func() { foo(); // 알아서 header1::foo() 가 실행된다. header2::foo(); // header2::foo() 가..

C++/모두의코드 2025.01.29