전체 글10 Lambda Functions Simple Explanation:outside the code (or in a separate file, class, etc.), without having to declare or define, inlining both the function declaration and implementation right where needed is provided as a convenience.In C++, function definitions typically live outside while internal code simply calls them, requiring you to jump around the codebase to understand behavior. Lambdas, however, keep e.. 2025. 4. 25. 람다 함수 (lambda function) 쉬운 설명 : 굳이 코드 바깥(혹은 별도 파일, 클래스 등)에 선언, 정의할 필요 없이, 함수 선언과 구현을 필요한 자리에서 "한꺼번에" inline으로 해 주는 편의성을 제공함.c++의 경우를 생각해 보면 함수 정의는 저 바깥에 있고 내부에선 그저 call을 하니 이것의 동작 여부를 알기 위해선 이곳 저곳 이동해야 한다. 그러나 lambda는 그 모든게 한 자리에 있어 가독성이 뛰어나다.거기에 이름도 필요없고 주변 변수도 캡처하여 사용 가능하며 일회성으로 간단한 연산에 매우 경제적으로 사용 가능하다! 1. 람다 함수를 사용한 예시사용 문법 : auto add = [](int x,int y){…};#include int main() { // 1) 람다를 정의해서 add 변수에 저장 auto a.. 2025. 4. 25. Delete 메모리 해제 (Malloc 에러) Delete 연산자 : 동적으로 할당된 메모리 해제 상황 이해를 위해 간단한 코드를 짜 보았다. 날짜에 대한 component를 가지는 구조체를 선언한다. main에서 동적 할당으로 관련 변수를 선언한 후 포인터를 이용, 클래스로 넘겨준다. 클래스는 초기화된 값을 받은 후 add_days라는 함수를 이용하여 며칠 정도의 날짜를 더하고 출력한다. #include typedef struct strDateComponent { int day; int month; int year;} date_comp;class Date { public: Date(date_comp* d); ~Date(); void add_days(int n); void pri.. 2024. 10. 24. gcc 로컬 설치(Without apt) 1. Prerequisites 프로그램gmpmpfrmpczlib gcc를 설치하기 전 필요한 dependency가 있는 프로그램들이다. 만약 sudo 권한 및 apt 패키지 매니징 프로그램이 있다면 아래 명령어로 다운 받을 수 있다.$ sudo apt update$ sudo apt install build-essential libgmp-dev libmpfr-dev libmpc-dev zlib1g-dev 그러나 필요한 경우 local에 직접 소스 코드를 다운받고 설치를 할 수 있다. 2. gmp 설치 (local에서 gcc 설치 시 prerequisites 첫 번째 프로그램)# GMP Install$ installDir=""$ if [ ! -f "gmp-6.2.1.tar.bz2" ]; then$ .. 2024. 10. 13. 이전 1 2 3 다음