Problem with a method from class

Hello programmers. Im having a bit of trouble with one method in my class called print_balance. Can someone help me out and tell me why its not working? Here is the program's main and the class being used.

#include <iostream>
#include <string>
#include "Account.h"

using namespace std;

const int NUM_ACCOUNTS = 3;
void main()
{
char name1 [SIZE_OF_NAME]= "Ralph Wilson";
char name2 [SIZE_OF_NAME]= "A. Conners";
char name3 [SIZE_OF_NAME]= "I. M. Overdrawn";

account **p = new account *[NUM_ACCOUNTS];

p [0] = new account(12387.87,name1);
p [1] = new account(144.00,name2);
p [2]= new account (-11.23, name3);

account temp_account= *p[0];
print_balance(temp_account); // not working method
}


/*************************************************************

#include <iostream>
#include <string>
#include <cstring>
using namespace std;
const int SIZE_OF_NAME=20;
class account
{

public:

account(double n, char *s) //constructor
{

name=new char[SIZE_OF_NAME];
strcpy_s(name, SIZE_OF_NAME,s);
cur_bal=n;
}

account(const account &rhs) //copy constructor
{
//account temp_account=account(rhs.cur_bal,rhs.name);
cur_bal = rhs.cur_bal;
name=new char[SIZE_OF_NAME];
strcpy_s(name, SIZE_OF_NAME, rhs.name);
cout<<"Copying account of " <<rhs.name<< endl;
}

~account();

double get_bal();

char *get_name();

void print_balance (account &account_to_print) // not working
{
cout<<"Balance of "<< account_to_print.name<<" is";
cout<< account_to_print.cur_bal <<endl;
}

void print_all_balances(account **p)
{
print_balance( *p[0]);
print_balance( *p[1]);
print_balance( *p[2]);

}

void delete_accounts(account **p);



private:
double cur_bal;
char *name;

};

account::~account()
{

}
void print_balance (account &account_to_print);

void print_all_balances(account **p);

void delete_accounts(account **p);
Topic archived. No new replies allowed.