Okay, this is driving me insane...

The compiler error I'm getting says I am trying to convert a void to an account? I don't see why it thinks I'm trying to do that... Maybe you guys can help me out.

void get_accounts(account a[], int n);
int add_customer(account a[], int n);

int main()
{
ifstream in_file("cur_customers.txt");

vector<account> vec_account;

get_accounts(in_file, vec_account, maximum_num_bills_allowed);

return 0;
}



void get_accounts(ifstream in_file, vector<account> v, int n);
{ int i;
while(!in_file.eof())
  { 
  string acct_num,first,last,address,city,state,phone;
  double balance, charge;
  int num_on_tab;
  account temp;
  
  infile>>acct_num>>first>>last>>address>>city>>state>>phone
        >>num_on_tab;

  for (i=0; i < num_on_tab; ++i)
    { 
    infile>>charge;
    temp.write_add_outstanding_bill_to_tab(charge);
    }
      
  
  temp.write_acct_num(acct_num);
  temp.write_first(first);
  temp.write_last(last);
  temp.write_address(address);
  temp.write_city(city);
  temp.write_state(state);
  temp.write_phone(phone);
  temp.write_num_on_tab(num_on_tab);


  v.push_back(temp);
  }
}

And these are the errors I am getting...

[pt084@cs program8]$ c++ code.cpp
code.cpp: In function `int main()':
code.cpp:226: invalid conversion from `void*' to `account*'
code.cpp:226: cannot convert `std::vector<account, std::allocator<account> >'
to `int' for argument `2' to `void get_accounts(account*, int)'
code.cpp: At global scope:
code.cpp:234: syntax error before `{' token
code.cpp:242: syntax error before `>>' token
code.cpp:245: syntax error before `;' token
code.cpp:248: syntax error before `.' token
code.cpp:252: syntax error before `.' token
code.cpp:253: syntax error before `.' token
code.cpp:254: syntax error before `.' token
code.cpp:255: syntax error before `.' token
code.cpp:256: syntax error before `.' token
code.cpp:257: syntax error before `.' token
code.cpp:258: syntax error before `.' token
code.cpp:259: syntax error before `.' token
code.cpp:262: syntax error before `.' token

-Thanks
Andy

I can't get that far without a definition of account, but your prototype doesn't match the definition.

Class definition:

#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;

const int maximum_num_bills_allowed=5;


class account{

private:
	string acct_num;
	string first;
	string last;
	string address;
	string city;
	string state;
	string phone;
	double balance;
	int num_on_tab;
	double outstanding_bills [maximum_num_bills_allowed];

	double intermediate_outstanding[maximum_num_bills_allowed];


public:
	account();

	account(string new_acct_num, string new_first, string new_last, string new_address,
		string new_city, string new_state);

	~account();

	//readers//

	string read_acct_num();
	string read_first();
	string read_last();
	string read_address();
	string read_city();
	string read_state();
	string read_phone();
	double read_balance();
	int    read_num_on_tab();
	double *read_outstanding_bills();

	//writers//

	void write_acct_num(string);
	void write_first(string);
	void write_last(string);
	void write_address(string);
	void write_city(string);
	void write_state(string);
	void write_phone(string);
	int  write_add_outstanding_bill_to_tab(double);
	int  write_remove_outstanding_bill_from_tab(double);
};


account::account()
{
	acct_num="";
	last="";
	first="";
	address="";
	city="";
	state="";
	balance=0.0;
	num_on_tab=0;
}

account::account(string new_acct_num, string new_first, string new_last, string new_address,
		string new_city, string new_state)
{
	acct_num=new_acct_num;
	first=new_first;
	last=new_last;
	address=new_address;
	city=new_city;
	balance=0.0;
	num_on_tab=0;
}

account::~account()
{}


//readers//

string account::read_acct_num()
{
	return acct_num;
}

string account::read_first()
{
	return first;
}

string account::read_last()
{
	return last;
}

string account::read_address()
{
	return address;
}

string account::read_city()
{
	return city;
}

string account::read_state()
{
	return state;
}

string account::read_phone()
{
	return phone;
}

double account::read_balance()
{
	return balance;
}

int account::read_num_on_tab()
{
	return num_on_tab;
}


double * account::read_outstanding_bills()
{
int i;
for(i=0; i < num_on_tab; ++i)
  intermediate_outstanding[i] = outstanding_bills[i];
return intermediate_outstanding;
}


//writers//

void account::write_acct_num(string new_acct_num)
{
	acct_num = new_acct_num;
}

void account::write_first(string new_first)
{
	first = new_first;
}

void account::write_last(string new_last)
{
	last = new_last;
}

void account::write_address(string new_address)
{
	address = new_address;
}

void account::write_city(string new_city)
{
	city = new_city;
}

void account::write_state(string new_state)
{
	state = new_state;
}

void account::write_phone(string new_phone)
{
	phone = new_phone;
}

int account::write_add_outstanding_bill_to_tab(double new_bill)
{ if(num_on_tab < maximum_num_bills_allowed)
    {
    outstanding_bills[num_on_tab] = new_bill;
    num_on_tab++;
    balance += new_bill;
    return 1;
    }
  else
    return 0;
}

int account::write_remove_outstanding_bill_from_tab(double paid_bill)
{ int i,k;

  for (i=0; i < num_on_tab && outstanding_bills[i] != paid_bill; ++i);

  if(i==num_on_tab)
    return 0;
  else
  {balance-=paid_bill;
  for (k=i+1; k < num_on_tab; ++k)
    outstanding_bills[k-1] = outstanding_bills[k];

  num_on_tab--;
  return 1;
  }
}

Okay, I fixed prototypes and then took away that semicolin I had after the function head (oops)

errors:

[pt084@cs program8]$ c++ code.cpp
/usr/include/c++/3.2.3/bits/ios_base.h: In copy constructor
`std::basic_ios<char, std::char_traits<char> >::basic_ios(const
std::basic_ios<char, std::char_traits<char> >&)':
/usr/include/c++/3.2.3/bits/ios_base.h:424: `std::ios_base::ios_base(const
std::ios_base&)' is private
code.cpp:226: within this context
/usr/include/c++/3.2.3/streambuf: In copy constructor `std::basic_filebuf<char,
std::char_traits<char> >::basic_filebuf(const std::basic_filebuf<char,
std::char_traits<char> >&)':
/usr/include/c++/3.2.3/streambuf:479: `std::basic_streambuf<_CharT,
_Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&)
[with _CharT = char, _Traits = std::char_traits<char>]' is private
code.cpp:226: within this context
code.cpp: In function `void get_accounts(std::basic_ifstream<char,
std::char_traits<char> >, std::vector<account, std::allocator<account> >,
int)':
code.cpp:242: `infile' undeclared (first use this function)
code.cpp:242: (Each undeclared identifier is reported only once for each
function it appears in.)
code.cpp:259: no matching function for call to `account::write_num_on_tab(int&)
'

I think you want to pass by reference both the ifstream and the vector.

void get_accounts(ifstream &in_file, vector<account> &v, int n)

Remove the semicolon at the start of the function definition (not the prototype). Note also in this file infile vs in_file. And write_num_on_tab seems to be missing.

Okay I fixed some things and now the only errors I'm getting now are:

[pt084@cs program8]$ c++ code.cpp
/usr/include/c++/3.2.3/bits/ios_base.h: In copy constructor
`std::basic_ios<char, std::char_traits<char> >::basic_ios(const
std::basic_ios<char, std::char_traits<char> >&)':
/usr/include/c++/3.2.3/bits/ios_base.h:424: `std::ios_base::ios_base(const
std::ios_base&)' is private
code.cpp:232: within this context
/usr/include/c++/3.2.3/streambuf: In copy constructor `std::basic_filebuf<char,
std::char_traits<char> >::basic_filebuf(const std::basic_filebuf<char,
std::char_traits<char> >&)':
/usr/include/c++/3.2.3/streambuf:479: `std::basic_streambuf<_CharT,
_Traits>::basic_streambuf(const std::basic_streambuf<_CharT, _Traits>&)
[with _CharT = char, _Traits = std::char_traits<char>]' is private
code.cpp:232: within this context


UPDATED CODE:

#include <iostream>
#include <string>
#include <fstream>
#include <vector>

using namespace std;

const int maximum_num_bills_allowed=5;


class account{

private:
	string acct_num;
	string first;
	string last;
	string address;
	string city;
	string state;
	string phone;
	double balance;
	int num_on_tab;
	double outstanding_bills [maximum_num_bills_allowed];

	double intermediate_outstanding[maximum_num_bills_allowed];


public:
	account();

	account(string new_acct_num, string new_first, string new_last, string new_address,
		string new_city, string new_state);

	~account();

	//readers//

	string read_acct_num();
	string read_first();
	string read_last();
	string read_address();
	string read_city();
	string read_state();
	string read_phone();
	double read_balance();
	int    read_num_on_tab();
	double *read_outstanding_bills();

	//writers//

	void write_acct_num(string);
	void write_first(string);
	void write_last(string);
	void write_address(string);
	void write_city(string);
	void write_state(string);
	void write_phone(string);
	void write_num_on_tab(int);
	int  write_add_outstanding_bill_to_tab(double);
	int  write_remove_outstanding_bill_from_tab(double);
};


account::account()
{
	acct_num="";
	last="";
	first="";
	address="";
	city="";
	state="";
	balance=0.0;
	num_on_tab=0;
}

account::account(string new_acct_num, string new_first, string new_last, string new_address,
		string new_city, string new_state)
{
	acct_num=new_acct_num;
	first=new_first;
	last=new_last;
	address=new_address;
	city=new_city;
	balance=0.0;
	num_on_tab=0;
}

account::~account()
{}


//readers//

string account::read_acct_num()
{
	return acct_num;
}

string account::read_first()
{
	return first;
}

string account::read_last()
{
	return last;
}

string account::read_address()
{
	return address;
}

string account::read_city()
{
	return city;
}

string account::read_state()
{
	return state;
}

string account::read_phone()
{
	return phone;
}

double account::read_balance()
{
	return balance;
}

int account::read_num_on_tab()
{
	return num_on_tab;
}


double * account::read_outstanding_bills()
{
int i;
for(i=0; i < num_on_tab; ++i)
  intermediate_outstanding[i] = outstanding_bills[i];
return intermediate_outstanding;
}


//writers//

void account::write_acct_num(string new_acct_num)
{
	acct_num = new_acct_num;
}

void account::write_first(string new_first)
{
	first = new_first;
}

void account::write_last(string new_last)
{
	last = new_last;
}

void account::write_address(string new_address)
{
	address = new_address;
}

void account::write_city(string new_city)
{
	city = new_city;
}

void account::write_state(string new_state)
{
	state = new_state;
}

void account::write_phone(string new_phone)
{
	phone = new_phone;
}

void account::write_num_on_tab(int new_num_on_tab)
{
	num_on_tab = new_num_on_tab;
}

int account::write_add_outstanding_bill_to_tab(double new_bill)
{ if(num_on_tab < maximum_num_bills_allowed)
    {
    outstanding_bills[num_on_tab] = new_bill;
    num_on_tab++;
    balance += new_bill;
    return 1;
    }
  else
    return 0;
}

int account::write_remove_outstanding_bill_from_tab(double paid_bill)
{ int i,k;

  for (i=0; i < num_on_tab && outstanding_bills[i] != paid_bill; ++i);

  if(i==num_on_tab)
    return 0;
  else
  {balance-=paid_bill;
  for (k=i+1; k < num_on_tab; ++k)
    outstanding_bills[k-1] = outstanding_bills[k];

  num_on_tab--;
  return 1;
  }
}


////start of main program////

void get_accounts(ifstream in_file, vector<account> v, int n);
int add_customer(account a[], int n);

int main()
{
ifstream in_file("cur_customers.txt");

vector<account> vec_account;

get_accounts(in_file, vec_account, maximum_num_bills_allowed);

return 0;
}



void get_accounts(ifstream &in_file, vector<account> &v, int n)
{ int i;
while(!in_file.eof())
  { 
  string acct_num,first,last,address,city,state,phone;
  double balance, charge;
  int num_on_tab;
  account temp;
  
  in_file>>acct_num>>first>>last>>address>>city>>state>>phone
        >>num_on_tab;

  for (i=0; i < num_on_tab; ++i)
    { 
    in_file>>charge;
    temp.write_add_outstanding_bill_to_tab(charge);
    }
      
  
  temp.write_acct_num(acct_num);
  temp.write_first(first);
  temp.write_last(last);
  temp.write_address(address);
  temp.write_city(city);
  temp.write_state(state);
  temp.write_phone(phone);
  temp.write_num_on_tab(num_on_tab);


  v.push_back(temp);
  }
}

Hey, thanks for all the help you're giving me. How long have you been doing this for?

Make sure the prototype matches the definition.

void get_accounts(ifstream in_file, vector<account> v, int n);
void get_accounts(ifstream &in_file, vector<account> &v, int n)

>How long have you been doing this for?
I've been moderating here since March. I've been participating in forums and such for a couple of years.

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.