Classes & arrays

Create a PlotNumbers class that has five data members to store five integer values from the user. It should have a 5-parameter constructor that can set the data members to the values provided as arguments, or a default value of 10. The class must also have a plot member function that uses a two-dimensional array to display the numbers as vertical bars. For example, the output for five numbers 2, 4, 3, 6, 3 would be
*
*
* *
* * * *
* * * * *
* * * * *
Write a client program that demonstrates the above class. It should plot two graphs, one for a PlotNumbers object created with default values, and another for the object that gets its five values from the user.

My code so far:

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
#include <iostream>
#include <string>
using namespace std;

class PlotNumbers
{
private:
		
	int num1,num2,num3,num4,num5;

	int plot(int rows[],int columns[]);
	
public:

	PlotNumbers(int n1,int n2,int n3,int n4,int n5)
	{
		num1 = n1;
		num2 = n2;
		num3 = n3;
		num4 = n4;
		num5 = n5;
	}

	PlotNumbers()
	{
		int allnum = 10;
		num1 = allnum;
		num2 = allnum;
		num3 = allnum;
		num4 = allnum;
		num5 = allnum;
	}
};

int main()
{
	int rows,columns;

	cout << "Enter the number of rows" << endl;
	cin >> rows;


I am confused now..abt how to have classes and arrays together.
THE STARS in the question are messed up.. it is supposed to be lined up as asked in the question
Last edited on
Topic archived. No new replies allowed.