Here is my code files
VectorNumbeList.cpp
#include <iostream>
#include "VectorNumberList.h"
void initialize() {
vect = new int[10];}
VectorNumberList.h
#include <vector>
#include <cstdlib>
#include "NumberList.h"
extern int* vect;
size_t size_real;
void initialize();
NumberList.h
#ifndef NUMBER_LIST_H
#define NUMBER_LIST_H
#include <cstdlib>
class NumberList {
public:
virtual void addNumberToList(int num) = 0;
virtual void removeNumberFromFront() = 0;
virtual void removeNumberFromBack() = 0;
virtual int getNumberAt(size_t index) = 0;
virtual size_t getSizeOfList() = 0;
virtual void clear() = 0;
void printNumbers();
void computeNextFibonacciAndInsertAtEnd();
void computeNFibonacci(size_t n);
void copyListIntoMe(NumberList &numList);
void reverseList();
};
#endif
runner.cpp
#include <iostream>
#include <string>
#include <vector>
#include "VectorNumberList.h"
int main() {
initialize();
return 0;
}
Makefile(runner is the folder name, different from runner.cpp)
CXX=g++
runner: runner.cpp VectorNumberList.cpp
$(CXX) runner.cpp VectorNumberList.cpp -o runner
clean:
rm runner *~
My error ends up being related to linking but I'm not sure as to how to solve it. Very confused, help would be much appreciated. ERROR STATEMENT
g++ runner.cpp VectorNumberList.cpp -o runner
/tmp/ccJYylpB.o:(.bss+0x0): multiple definition of `size'
/tmp/ccLyM4kA.o:(.bss+0x0): first defined here
/tmp/ccJYylpB.o: In function `initialize()':
VectorNumberList.cpp:(.text+0x11): undefined reference to `vect'
collect2: error: ld returned 1 exit status
Makefile:3: recipe for target 'runner' failed
make: *** [runner] Error 1
I've tried modifying the include statements by removing them in runner.cpp or vectornumberlist.cpp, but I've had no luck. I'm very lost because I'm new to C++. It has something to do with the header file but I'm not sure on how to approach, besides removing the vect and size variables from the vectornumberlist.h file.