So I have some .cc and .h files.
// Class.cc
#include "Class.h"
Class::Class(){
this->x = 1;
this->y = new HelpingClass[1];
y[0] = HelpingObject{}; // Calls the HelpingObject's default ctor
}
So this is my main .cc file where I have created a constructor for my Class, which is defined in my Class.h file:
// Class.h
#include "HelpingClass.h"
struct Class{
HelpingObject * y; // heap allocated array of HelpingObject
int x; // size of allocated array
Class(); // The constructor
...
}
This "HelpingObject" is included in my HelpingClass.h with a working HelpingClass.cc also in my VScode file (I know the HelpingClass implementation works well already so I'm ommitting HelpingClass.cc):
// HelpingClass.h
struct HelpingObject {
int a;
int b;
HelpingObject(int a = 0, int b = 10);
}
// Doesn't really matter what this object is, but my "Class" has a field
// which is a heap allocated array of these objects
The problem is, I'm getting and error that says "Class.cc:(.text+0x43): undefined reference to `HelpingObject::HelpingObject(int, int)' collect2.exe: error: ld returned 1 exit status"
What is ths? I'm using VSCode if that helps, but even if I make a Makefile with an executable with all these files in linux, I get the same error. Please help
edit: I changed the name of my actual code to these general names to make it easier but I messed up in copying it over to here haha. The syntax is all correct in my code, my implementation isnt'