BugDict/C++

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++] "Incomplete Types" 해결

이 글에서는 C++에서 발생하는 "incomplete types" 에러를 이해하고 이를 해결하는 방법을 설명합니다. 문제상황 // main.cpp #include #include "Container.h" int main() { Container container; container.addItem(10); container.addItem(20); std::cout

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..

BugDict/C++

[C++] "ambiguous overload for 'operator<<' (operand types are 'std::ostream' and 'const MyClass')" 해결

문제상황: 클래스를 활용한 C++ 개발 중, 클래스 내의 멤버 변수를 출력하려고 할 때 오버로딩한 operator

BugDict/C++

[C++] "unresolved external symbol" 해결

문제상황: 다음과 같은 C++ 코드를 작성하고 컴파일을 실행했을 때, unresolved external symbol 에러가 발생했습니다. #include class MyClass { public: void printMessage(); }; int main() { MyClass obj; obj.printMessage(); return 0; }에러로그 내용: error LNK2019: unresolved external symbol "public: void __cdecl MyClass::printMessage(void)" (?printMessage@MyClass@@QEAAXXZ) referenced in function main해결방법: 해결된 코드와 수정된 부분에 대한 주석을 보여드리겠습니다. #incl..

Bug Detector
'BugDict/C++' 카테고리의 글 목록