I am working on a project and need to split the code into different files. I looked up tutorials on youtube because I had no idea how to spit code into different files. So I just followed a youtube tutorial exactly word by word, but after everything, the tutorial video code printed out the result but mine did not even after doing the exact same thing. But it just prints out the following in the terminal.
PS C:\Users\david\OneDrive\Desktop\account> cd "c:\Users\david\OneDrive\Desktop\account\" ; if ($?) { g++ bank.cpp -o bank } ; if ($?) { .\bank }
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\david\AppData\Local\Temp\ccCetn85.o:bank.cpp:(.text+0x26): undefined reference to `Date::Date(int, int, int)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\david\AppData\Local\Temp\ccCetn85.o:bank.cpp:(.text+0x32): undefined reference to `Date::display()'
collect2.exe: error: ld returned 1 exit status
This is the main file
// MAIN FILE
#include<iostream>
#include<string>
#include "account.h"
using namespace std;
int main(){
Date val(2,12,2015);
val.display();
}
This is the account.cpp file
// account.cpp FILE
#include "account.h"
Date::Date(int month, int day, int year){
this->day = day;
this->month = month;
this->year = year;
}
void Date::display(){
cout << month << "/" << day << "/" << year << "/" << endl;
}
This is account.h file
// account.h FILE
#pragma once
#include <iostream>
using namespace std;
class Date{
private:
int day,month,year;
public:
Date(int month = 1, int day = 1, int year = 2022);
void display();
};
I am really lost on this I can't find any solutions. Any help is really appreciated. Thank you in advanced.