Also stoi and exit(0) are both out of scope in stk.cpp and I don\'t know why.
Here is main.cpp
#include \"stk.h\" int main() { cout << \"R
The problem is that you are not linking the code from stk.cpp when creating the executable.
Solution 1: Compile the .cpp files first and then link.
g++ -c main.cpp g++ -c stk.cpp g++ main.o stk.o -o test
Solution 2: Compile and link both files in one step.
g++ main.cpp stk.cpp -o test