본문 바로가기
728x90

전체 글162

CPP 부모클래스에서 virtual 함수가 하나라도 있으면 소멸자도 무조건 virtual? cpp 공부를 하며 여러 가지 테스트를 진행 중, 이상한 상황을 발견했다! class A { A() {}; ~A() {}; virtual void test1() {}; }; class B : A { } int main() { A a = new B(); delete a; } 위와 같이 코드를 적었을 때 컴파일 오류가 난다. 원래 업 캐스팅을 할 때는 자식 클래스의 소멸자가 호출되지 않기 때문에 부모 클래스의 소멸자를 virtual로 설정해서 가상 함수 테이블을 만들어 줘야 된다. 부모 클래스의 소멸자를 virtual로 설정하는 것이 좋다~이지 필수는 아니라고 알고 있어서 위의 코드에서 컴파일 오류를 마주했을 때 왜 오류가 뜨는지 몰랐다. 밑에 코드와 같이 A class(부모)에서 virtual 함수가 없으.. 2022. 3. 10.
leetcode 2) Add Two Numbers LV. Medium 🧐 https://leetcode.com/problems/add-two-numbers/ Add Two Numbers - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains.. 2022. 3. 10.
leetcode 799) Champagne Tower LV. Medium 🧐 https://leetcode.com/problems/champagne-tower/ Champagne Tower - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row. Each glass holds one cup of .. 2022. 3. 4.
leetcode 338) Counting Bits LV. Easy 😎 https://leetcode.com/problems/counting-bits/ Counting Bits - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 Given an integer n, return an array ans of length n + 1 such that for each i (0 2022. 3. 1.
leetcode 228) Summary Ranges LV. Easy 😎 https://leetcode.com/problems/summary-ranges/ Summary Ranges - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 You are given a sorted unique integer array nums. Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each el.. 2022. 2. 28.
leetcode 165) Compare Version Numbers LV. Medium 🧐 https://leetcode.com/problems/compare-version-numbers/ Compare Version Numbers - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 Given two version numbers, version1 and version2, compare them. Version numbers consist of one or more revisions joined by a dot '.'. Eac.. 2022. 2. 25.
leetcode 148) Sort List LV. Medium 🧐 https://leetcode.com/problems/sort-list/ Sort List - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 Given the head of a linked list, return the list after sorting it in ascending order. Example 1: Input: head = [4,2,1,3] Output: [1,2,3,4] Example 2: Input: head = [.. 2022. 2. 24.
leetcode 133) Clone Graph LV. Medium 🧐 https://leetcode.com/problems/clone-graph/ Clone Graph - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 문제 Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) and a list (L.. 2022. 2. 23.
[한빛 미디어] 이것이 안드로이드다 with 코틀린(개정 3판) "한빛미디어 활동을 위해서 책을 제공받아 작성된 서평입니다." 저는 안드로이드 애플리케이션을 자바로만 개발을 해봤습니다. 그러나 요즘 기업 기술 스택을 보니 코틀린을 많이 선호하는 것 같았습니다. 그래서 코틀린이 무슨 언어이고, 안드로이드 앱을 어떻게 개발하는지 궁금해져 이 책을 읽게 되었습니다. "이것이 안드로이드다 with 코틀린"은 1판, 2판, 3판으로 이루어져 있습니다. 개정 몇 판을 보면 좋을지 고민이 되어 목차를 확인해봤는데, 1판 2판 3판의 내용이 이어져 있는 것이 아니라 다 안드로이드의 구조부터 설명이 되어 있었습니다. 저는 3판의 실습 내용이 더 맘에 들어 3판으로 결정하게 되었습니다! 다른 분들도 1판 2판 3판의 실습 예제를 보고 더 맘에 드는 책을 잘 고르셨으면 좋겠어요ㅎㅎㅎ 저.. 2022. 2. 23.
728x90