I'm running VScode on an M1 Mac. I keep getting this error whenever I try to run my code:
Undefined symbols for architecture arm64:
"Array::Array(int)", referenced from:
_main in Main-528956.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This is a pretty simple project for a c++ class but this error is out of my league. Here are the three classes I have to use:
Array.h :
#ifndef _ARRAY_H_
#define _ARRAY_H_
class Array
{
public:
Array();
Array(int);
private:
int size;
int *arr;
};
#endif
Array.cpp :
#include <iostream>
#include "Array.h"
using namespace std;
Array::Array()
{
size = 0;
arr = nullptr;
}
Array::Array(int s)
{
size = s;
arr = new int[size];
for (int i = 0; i < size; i++)
{
arr[i] = i;
}
cout << "overloaded constructor works" << endl;
delete[] arr;
}
main.cpp :
#include <iostream>
#include "Array.h"
using namespace std;
int main()
{
Array arr1(5), arr2(10);
return 0;
}
Let me know if I need to add any other information.