Hello~
I'm working on a project in which we are suppose to create our own class seperating the class and the implementation. When i try to compile the .cpp file im getting 2 errors on line 10: 1. new types may not be defined in a return type and 2. return type specification for constructor invalid. Unfortunately i have no clue what im doing wrong here. Any help would be greatly appreciated, thx.

This is my header file, Account.h.

#include <iostream>
using namespace std;
class Account
{
      public:
             Account(int newAccNumber);
             Account();

             void setAccNumber(int newAccNumber);
             void setPaymentAmount(double newPaymentAmount);
             void setInterestRate(double newInterestRate);
             void setPaymentsRemaining(int newPaymentsRemaining);
             int getAccNumber();
             double getPaymentAmount();
             double getInterestRate();
             int getPaymentsRemaining();
             double getAmountOwed();

      private:
              int accNumber;
              double paymentAmount;
              double interestRate;
              int paymentsRemaining;

              double calcAmountOwed();              
};

Here is my Implementation file, Account.cpp.

#include <iostream>
#include <iomanip>
#include <math.h>
#include <cstdlib>
using namespace std;
#include "Account.h"

Account::Account(int newAccNumber)
{
     accNumber = newAccNumber;               
}
Account::Account()
{
     accNumber = 0;
     paymentAmount = 0.00;
     interestRate = 0.00;
     paymentsRemaining = 0;
}

void Account::setAccNumber(int newAccNumber)
{
     accNumber = newAccNumber;
}
void Account::setPaymentAmount (double newPaymentAmount)
{
     paymentAmount = newPaymentAmount;
}
void Account::setInterestRate (double newInterestRate)
{
     interestRate = newInterestRate;
}
void Account::setPaymentsRemaining (int newPaymentsRemaining)
{
     paymentsRemaining = newPaymentsRemaining;
}
int Account::getAccNumber()
{
    return accNumber;
}
double Account::getPaymentAmount()
{
    return paymentAmount;
}
double Account::getInterestRate()
{
    return interestRate;
}
int Account::getPaymentsRemaining()
{
    return paymentsRemaining;
}
double Account::getAmountOwed()
{
       return calcAmountOwed();
}
double Account::calcAmountOwed()
{
      return paymentAmount * ( (1 - pow((1+(interestRate/12)),-interestRate*12) ) / (interestRate/12) ); 
}

I don't get any errors or warnings when compiled with my compiler -- VC++ 2005 Pro. Maybe you don't have your project set up correctly. Your code is ok.

Code is okay..
May be the pre-processor is screwing up somewehre. Do only preprocessing and check the output. Also hope that you've posted complete code.
Is the error in .cpp or .h? What compiler are you using?
Don't do "using namespace std;" in header file. You'll run into trouble when you code the clients of Account class.

turns out i neglected to put it into a project, thank you for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.