본문 바로가기

전체 글38

[C++] 다형성과 오버로딩, 오버라이딩 다형성이란부모객체를 선언하고 자식객체로 초기화해서 런타임시 다양한 실제타입에 따라 다른 메서드를 사용할 수 있게 하는 동적 다형성과 한 스코프 내에서 함수를 선언할 때 같은 이름의 함수를 다른 타입의 파라미터로 정의하는 정적 다형성이있다.오버라이딩과 가상함수 virtual오버라이딩은 부모의 객체의 메서드를 자식 객체가 재정의 할 수 있게 하는 기능이다.그런데 다형성을 지원하는 C++에서 부모 개체로 선언된 자식 객체의 경우 특정 오버러이딩 메소드를 호출하면 이 메소드는 부모의 메소드를 불러올까 아니면 자식의 메소드를 불러올까?Virtual은 여기서 작동한다. Virtual을 함수 앞에 선언하면 함수를 선언할 때 자식 클래스의 메소드가 이 메소드를 덮어 쓸 수 있게 해준다.그런데 무슨원리로?이런 기능을 들.. 2024. 6. 22.
[Leetcode 1052번 문제] 1052. Grumpy Bookstore Owner 문제 상황There is a bookstore owner that has a store open for n minutes. Every minute, some number of customers enter the store. You are given an integer array customers of length n where customers[i] is the number of the customer that enters the store at the start of the ith minute and all those customers leave after the end of that minute.On some minutes, the bookstore owner is grumpy. You are giv.. 2024. 6. 21.
[네트워크] TCP, UDP 프로토콜 들어가며지난번에 IP 관련 공부를 했다. 그럼 당연히 이제 전송 계층 공부를 할 차례 잠깐 들어가기전에 지난번 IP 패킷의 정보를 담고있는 IP헤더의 구조와 크기를 정리해봤다전송 계층 공부전송계층을 공부하게되면 누구나 TCP, UDP라는걸 배우게된다. 일단 둘은 판이하게 다르고 실제로 응용프로그램 계층의 프로토콜들도 UDP냐 TCP냐에 따라서 목적과 용도가 다르다는걸 알 수 있었다. 사실상 우리가 인터넷 계층에서 사용하는 프로토콜은 IP가 대부분이라는걸 생각하면 ( 실제로 UDP와 TCP도 둘다 IP프로토콜을 사용한다고한다) 둘의 차이점이나 구성을 명확히 파악해야 할 것 같다.일단 책에서 배운것을 기반으로 둘의 차이를 생각해보면TCP연결성이다데이터들의 도착순서가 보장된다.가상회선 방식을 사용한다위의 이유.. 2024. 6. 19.
[Leetcode 826번 문제] 826. Most Profit Assigning Work 문제 상황You have n jobs and m workers. You are given three arrays: difficulty, profit, and worker where:difficulty[i] and profit[i] are the difficulty and the profit of the ith job, andworker[j] is the ability of jth worker (i.e., the jth worker can only complete a job with difficulty at most worker[j]).Every worker can be assigned at most one job, but one job can be completed multiple times.For ex.. 2024. 6. 18.