Calculator.h
#ifndef CALCULATOR_H
#define CALCULATOR_H
class Calculator
{
public:
void run();
};
#endif
Calculator.cpp
#include <iostream>
using namespace std;
#include "Calculator.h"
#include "Adder.h"
void Calculator::run(){
cout << "두 개의 수를 입력하세요>>";
int a, b;
cin >> a >> b;
Adder adder(a,b);
cout << adder.process();
}
Adder.h
#ifndef ADDER_H
#define ADDER_H
class Adder
{
int op1, op2;
public:
Adder(int a, int b);
int process();
};
#endif
Adder.cpp
#include "Adder.h"
Adder::Adder(int a, int b)
{
op1 = a;
op2 = b;
}
int Adder::process()
{
return op1 + op2;
}
main.cpp
#include "Calculator.h"
int main(){
Calculator calc;
calc.run();
return 0;
}
Error
Executing task in folder Basic: /usr/bin/g++ -std=c++11 -g /Users/youblue/Documents/Basic/C++/HelloWorld/cpp_programming_class/week_3/main.cpp -o /Users/youblue/Documents/Basic/C++/HelloWorld/cpp_programming_class/week_3/main.out < Undefined symbols for architecture arm64: "Calculator::run()", referenced from: _main in main-a40f82.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation) The terminal process "zsh '-c', '/usr/bin/g++ -std=c++11 -g /Users/youblue/Documents/Basic/C++/HelloWorld/cpp_programming_class/week_3/main.cpp -o /Users/youblue/Documents/Basic/C++/HelloWorld/cpp_programming_class/week_3/main.out'" failed to launch (exit code: 1). My laptop is M1 MBP.
I can't compile main.cpp in vscode.