I am having issues getting my files to compile in unix. I am following along with the online example given. the online instructors is compiling(in vm). mine is not compiling in unix.
here are the errors:
account.cpp:16: error: declaration of âdouble Account::deposit(double) throw (NotPositiveDeposit)â throws different exceptions
account.h:20: error: from previous declaration âdouble Account::deposit(double)â
account.cpp:25: error: no âdouble Account::withdraw(double)â member function declared in class âAccountâ
and finally out of curiosity....Why would the instructor code it this way (have it compile for him), but then come to find out it is not even necessary?
fixed the typo and now this is what is shown when I compile:
157% g++ account.cpp -o account
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
when I compile the bankaccount.cpp code(nothing was changed from the above version. these are the errors listed:
In function `main':
bankaccount.cpp:(.text+0x1b): undefined reference to `Account::Account(double)'
bankaccount.cpp:(.text+0x4b): undefined reference to `Account::deposit(double)'
bankaccount.cpp:(.text+0x11c): undefined reference to `Account::~Account()'
bankaccount.cpp:(.text+0x138): undefined reference to `Account::~Account()'
collect2: ld returned 1 exit status
#include<iostream>
#include"account.h"
usingnamespace std;
int main()
{
Account a(300);
try
{
cout << "Deposit 150"<< endl;
cout<< "The new balance is: "<< a.deposit(150)<<endl;
}
catch(NotPositiveDeposit)
{
cout<< " The amount attempting to deposit must be positive"<< endl;
}
catch(InvalidWithdrawal)
{
cout<<"This is an invalid withdrawal amount."<<endl;
}
return 0;
}