Classes & Vectors

Working on a project on a class named "budget". We were instructed to pretty much stuff everything into a .h file and not worry about .cpp files in the meantime. This is what I have so far. I commented out the remaining things I need help with. Any information would help!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  #pragma once
#include <vector>

class Budget
{
private:
	std::vector <double> expenses;
	std::vector <double> income;
	double budget;


public:
	Budget();
	Budget(double);
	void EditIncome(int, double);
	void DeleteIncome(int);
	void DeleteExpense(int);
	void AddExpense(double);
	void AddIncome(double);
	double CalculateBudget();

};

Budget::Budget(double budget)
{
	this->budget = budget;
}

void Budget::AddExpense(double value)
{
	expenses.push_back(value);

	//Need to pushback value into vector
	//Need -> array[index] = value;
}

void Budget::AddIncome(double add) // argument needed
{
	income.push_back(add);

	//same as above
}

double Budget::CalculateBudget()
{


	//Need the sum of all income
	//Need sum of all expenses
	//Need to subtract expenses from income
	//Need to store value into budget
	//Need to return budget
}
To get the sum of all income and expenses you can use std::accumulate if you are allowed to otherwise you have to use a loop.
http://www.cplusplus.com/reference/numeric/accumulate/
Topic archived. No new replies allowed.