Each .cpp file is compiled independently into an object file (.obj):
BinaryTrees.cpp→BinaryTrees.objBinaryTreeSearchInsert.cpp→BinaryTreeSearchInsert.objDelete.cpp→Delete.objMain.cpp→Main.obj
The linker combines all .obj files into one executable:
- Links function calls to their definitions
- Resolves all references between files
- Creates the final .exe
Features: Simple tree creation, inorder traversal
Use in Main.cpp: #include "BinaryTrees.h"
Features: Insert, Search, Inorder traversal
Use in Main.cpp: #include "BinaryTreeSearchInsert.h"
Features: Insert, Search, Delete, Inorder traversal
Use in Main.cpp: #include "Delete.h"
// VERSION 1 - Basic
#include "BinaryTrees.h"
// VERSION 2 - With Insert/Search
// #include "BinaryTreeSearchInsert.h"
// VERSION 3 - With Delete
// #include "Delete.h"Right-click each .cpp file → Properties → Excluded From Build
- To use Version 1: Exclude BinaryTreeSearchInsert.cpp and Delete.cpp
- To use Version 2: Exclude BinaryTrees.cpp and Delete.cpp
- To use Version 3: Exclude BinaryTrees.cpp and BinaryTreeSearchInsert.cpp
- Header files (.h): Declarations only (what exists)
- Source files (.cpp): Definitions (how it works)
- #pragma once: Prevents including the same header twice
- One definition rule: Each class/struct can only be defined once across all files
- Main.cpp: Only include ONE version's header at a time
✅ Fixed: Missing semicolon in Delete.h ✅ Fixed: Added missing function implementations ✅ Each version is now self-contained