Issue with compiling and running c++ program on scite

249 Views Asked by At

So I'm just writing a simple c++ program and I am having some issues running the program. I could build my make file but when I try to run the testfile it gives me an "collect2.exe: error: ld returned 1 exit status" error, "undefined reference to Account::Account(int, double, double)" and basically all of my methods. I've attached a picture of my .h file, and .cpp below.

.h File

.cpp file

And the test file is like this :

#include <iostream>
#include <string>
#include <iomanip>
#include "Account.h"

using namespace std;

int main(){

Account account1(1122, 20000, 4.5);

account1.withdraw(2500);
account1.deposit(3000);

cout<<"Account Information"<<endl
<<"ID: " << account1.getID()<<endl
<<"Balance: " << account1.getBalance()<<endl
<<"Monthly Interest Rate: " << account1.getMonthlyInterestRate()<< endl;

return 0;
}

Make file:

TestAccount: TestAccount.o Account.o
    g++ TestAccount.o Account.o -o TestAccount
TestAccount.o: TestAccount.cpp Account.h
    g++ -c TestAccount.cpp
Account.o: Account.cpp Account.h
    g++ -c Account.cpp
0

There are 0 best solutions below