람다 함수

BugDict/C++

[C++] "invalid use of member function" 해결

이 글에서는 C++에서 발생하는 "invalid use of member function" 에러의 원인 및 해결 방법에 대해 자세히 설명하고 있습니다. 실무에서 사용될 수 있는 코드 예제를 기반으로, 에러의 발생 원인을 분석하고 몇 가지 해결 방법을 제시합니다. 문제상황 아래와 같은 에러가 발생한 코드를 살펴보겠습니다. #include #include #include class Employee { public: Employee(const std::string& name, int age, double salary) : m_name(name), m_age(age), m_salary(salary) {} bool is_higher_salary(const Employee& other) const { return ..

BugDict/C++

[C++] "no matching function for call to 'function_name'" 해결

이 글에서는 C++에서 흔히 발생하는 "no matching function for call to 'function_name'" 에러를 해결하는 방법에 대해 설명합니다. 문제 상황과 원인 분석, 그리고 두 가지 해결 방법을 자세히 살펴봅니다. 문제상황 아래는 실무에서 사용될 수 있는 코드의 예시입니다. 이 코드에서는 사용자 정의 클래스 CustomVector와 이 클래스의 인스턴스를 정렬하는 함수 sort_custom_vectors를 사용하고 있습니다. #include #include #include class CustomVector { public: int x, y; CustomVector(int x, int y) : x(x), y(y) {} }; bool compare_custom_vectors(co..

Bug Detector
'람다 함수' 태그의 글 목록