Thread: Multi. source files?

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    4

    Multi. source files?

    I'm having problems with this program and it seems to be in my header file can anyone guide me in the right direction?
    Code:
    //Header file for Checking Account Program
    //CheckAccount.h
    
    class CheckAccount
    {
    	Public:
    	CheckAccount (int date, string name, float balance);
    	void withdraw ()float;
    	void deposit ()float;
    	float CurrentBalance ();
    
    	Private:
    	AccountopenDate (y,m,d);	//Considering a struct
    	AccountOwner(string name);
    	CurrentBalance(float balance);
    
    };
    Code:
    //Implement
    //CheckAccount.cpp
    
    #include <iostream>
    #include "CheckAccount.h"
    
    using namespace std;
    
    CheckAccount::CheckAccount(int date, string name, float balance)
    {
    	AccountOpenDate = date;
    	struct AccountOpenDate
    	{
    		int year;
    		int month;
    		int day;
    	};
    
    	
    	AccountOwner = name;
    	CurrentBalance = balance;
    	
    	
    }
    
    void CheckAccount::withdraw(float)
    {
    	cout<<"Cash Amount Wanted: "<<endl;
    	cin>>w;
    	
    }
    
    void CheckAccount::deposit(float)
    {
    	cout<<"Amount Deposited: "<<endl;
    	cin>>d;
    
    }
    
    float ChechAccount::CurrentBalance(float)
    {
    	Switch balance
    	{ 
    		case d:
    			CurrentBalance=balance+Deposit;
    			cout<<CurrentBalance;
    			break;
    
    		case w:
    			CurrentBalance=balance-Withdraw;
    			cout<<CurrentBalance;
    			break;
    
    		default:
    			cout<<"Error made"<<endl;
    			break;
    	};
    
    }
    Thank You.

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    The problem is that you capitalised 'public' and 'default'. Remember, C++ is a case-sensitive language meaning that Foo is not the same as foo nor FoO. There are many more mistakes, in fact. You are also capitalizing 'switch'. The worse thing you are doing is creating a structure inside the constructor... This has to be done outside of it. I really suggest you to read some basic book or tutorial because there are very very very basic mistakes there that you shouldn't be doing if you are touching classes and structs.

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    Start with an empty class and get it to compile before continuing. Then add a function, or a constructor, or a data member and get it to compile before continuing. Keep compiling after each step and fixing any errors that come up before moving on to the next piece of code.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 06-04-2009, 08:45 PM
  2. How to create a C project with multiple source files
    By MSF1981 in forum C Programming
    Replies: 5
    Last Post: 03-22-2009, 09:25 AM
  3. Confusion on header and source files
    By dnguyen1022 in forum C++ Programming
    Replies: 4
    Last Post: 01-17-2009, 03:42 AM
  4. pseudocode for multiple source files
    By Calef13 in forum C++ Programming
    Replies: 4
    Last Post: 11-13-2007, 09:07 AM
  5. Multi - File Program not finding files
    By johnh444 in forum C++ Programming
    Replies: 2
    Last Post: 07-03-2004, 01:48 AM