Hope someone can help. I'm self-studying from C++ Primer Plus, 5th Edition. I'm having trouble working out why the following two files will not compile. I'm using Dev-C++, under Windows Vista.
/*
Name: bankaccount.h
Copyright:
Author: Steven Taylor
Date: 28/01/08 14:04
Description: C++ Primer Plus, Chapter 10, Programming Exercise. #1. Page 496
*/
#ifndef BANKACCOUNT_H_
#define BANKACCOUNT_H_
class BankAccount
{
private:
char name[40];
char acctnum[25];
double balance;
public:
BankAccount(const char *client, const char *num, double bal = 0.0);
void deposit(double cash);
void withdraw(double cash);
void show() const;
}
#endif
And this file:
/*
Name: bankaccount.cpp
Copyright:
Author: Steven Taylor
Date: 28/01/08 14:03
Description: BankAccount class methods. C++ Primer Plus, Chap 10, page 496
*/
#include <iostream>
#include <cstring>
#include "bankaccount.h"
BankAccount::BankAccount(const char *client, const char *num, double bal)
{ // error reported here - cannot
strncpy(name,client,39);
name[39] = '\0';
strncpy(acctnum, num,24);
acctnum[25] = '\0';
balance = bal;
}
When trying to compile the above I get an error reported in the second file at the first brace indicating 13 D:\Users\Steve\Documents\LearningCpp\LearningCppPrimer\Chapter-10\PE-01\bankaccount.cpp new types may not be defined in a return type
Very next error message is 13 return type specification for constructor invalid
Both files are in the same directory. Can somebody point me in the right direction.