--- In [email protected], "Onesmo" <[EMAIL PROTECTED]> wrote: Hi,
I'mno expert but I would like to help. Before goign into any detail I see that you are mixing C with C++. You have the follwoing libraries: #include<iostream.h> #include<string.h> the iostream library is a C++ library. SO, you must call it this way : #include <iostream> Note that it does not have the .h extension. This is the way standart C++ libraries are called. C libraries have the .h. Note that iostream does not exist for C. To use the C equivalent then you must call #include <stdio.h> The library <string.h> is a C library. the C++ version is <string>. Again witout the .h at the end. These are two different libraries. In C if you want to copy one string to another you can use strcpy just like you are doing below. However, if you use the C++ equivalent <string> then you do not use strcpy or strcmp or all the others. You can get away with something like: name=name+"none"; or name=+"none"; Here is the thing. You must choose wich languange you want to use. Is somewhat ok to build a C program in a C++ language. That is you can use the C libraries to some extend. However, you cannot use the C++ libraires in a C program. I notice that you are using a class. There is no class keyword in C. The closest C has is a structure and you cannot have functions (methods if you want to get technical) inside a structure in C. So, since you already have some work already in C++ just stick with that. Plus the type of program you are writting seem to play wel with object oriented thinking. For now, change the libraries to the C++ equivalent and then tell us how it goes. P.S. If you decide you are going the C++ route then why not use constructors. The constructor is used to initialised variables inside a class. That is it initializes the object. If I don't say it properly I'll get repremended hehehe. Anyways, once you have a well define constructor then you can do something like CUSTOMER jame; //its a good idea to name your classes in upper case. Makes for god visual aid. with that the variables (memebers if you want to get technical)inside the object james will be initialised to the default values like balance =0.0; address="none" acountNumber="none" etc etc. for a nice tutorial refer to these links 1) http://www.cplusplus.com/doc/tutorial/ 2) http://www.bgsu.edu/departments/compsci/docs/string.html 3) http://yolinux.com/TUTORIALS/LinuxTutorialC++StringClass.html > > I was doing my project and came up with codes to creat bank Accounts > the question want to creat Saving Account which will include interst > rate,current account with over draftand fixed term deposit account > with interest rate and number of years. > > company employees should be able to > - creat new account > - view and update accounts > - make deposit and withdraw > > > coustomers should > - view account > -make deposit > -make withdraw > -and view statement > > > but now I am stuck nothing works > > please needs help > > [code] > #include<iostream.h> > #include<string.h> > #include"account.h" > > > > customer::customer(void) > //constructor of the > customer class > { > > strcpy(name,"none"); > // Initialiazing name > strcpy(address,"none"); > //initialising address > //address1=0; > //initializing house > number to 0 > AccNumber > =0; //initialising > number 0 > > } > > > void customer::set_name(char customer_names[]) > { > strcpy(name,customer_names); > } // Initialiazing name > char*customer::get_name(void){return name;} > // retrieve > customer name > void customer::set_address(char customer_address[]){strcpy > (address,customer_address);} > char*customer::get_address(void){return address;} > void customer::set_AccNumber(int length){AccNumber=length;} > int customer:: get_AccNumber(void){return AccNumber;} > // retrieve AccNumber number > > > > > //void customer::set_address1(int length1){length1=new_address1;} > //int customer::get_address1(void){return new_address1;} > > > customer::~customer(void) // > > { > > strcpy(name,"none"); > strcpy (address,"none"); > > } > #ifndef ACCOUNT_H > #define ACCOUNT_H > #include<iostream.h> > > > class customer // class customer to customer store details > > { > private: > > char name [30]; // stores customers name > char address[50]; //stores customers address > //int address1; //store house number of > address > int AccNumber; //stores customers account number > int new_address1; > > > public: > > customer > (void); //customer > function > void set_name(char customer_names[]); //Set Name > function > char* get_name > (void); //Get name > function > void set_address (char new_address[]); //set > address function > char*get_address > (void); //get address > function > void set_AccNumber(int > length); //set accNumber function > int get_AccNumber > (void); //get > accNumber function > void printcustomer(); > > //void set_address1(int length1); > //int get_address1(void); > ~customer > (void); //Destructor > > }; > > #endif > > > > > > > #include<iostream.h> > #include<string.h> > #include"account.h" > //#include<current_acc.h> > > account::account(void) > > { > > balance = 0.0; > > } > > > > float account::account_balance(void) > > { > > return balance; > > } > > > > float account::withdraw(float money) > > { > > if ( money <= balance ) > > { > > balance = balance-money; > > return money; > > } else { > > return 0; > > } > > } > > > > > > #ifndef ACCOUNT_H > #define ACCOUNT_H > #include<iostream.h> > //#include<current_acc.h>/ > //Class Account > > class account { > > public: > account(void); > > float acc_balance(); > > float acc_withdraw( float ); > > void acc_deposit( float ); > > > > private: > > float balance; > > }; > > > #endif > [/code] >
