Storing an array in an object

Hi,

I am wondering how to create an array to store the values that are user inputted for the filter (ValueFilter) and how to define the length of that array using the LengthFilter value also user inputted.

Thanks Neil


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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define FILTER_FILENAME "filter.txt"
#define FILTER_MAX 100

class TheFilter {
public:
	TheFilter();
	~TheFilter();
	void EnterFilter();
	void ShowFilter();
	void Valid();
	void LoadFilter();
	void SaveFilter() const;
private:
	double LengthFilter;
	int ValueFilter;
};

TheFilter::TheFilter() {
	ValueFilter = 0;
	LengthFilter = 0;
}

TheFilter::~TheFilter() {
	cout << "Filter deleted" << endl;
}

void TheFilter::EnterFilter() {
	cout << "Please enter the number of values in the filter" <<endl;
	cout << "-----------------------------------------------" <<endl;
	cin >> LengthFilter;
	cout << "Please enter the values of the filter" <<endl;
	cout << "-------------------------------------" <<endl;
	cin >> ValueFilter;
	cout << "Filter entered" <<endl;
}

void TheFilter::ShowFilter() {
	cout << "The filter is" << ValueFilter <<endl;
}

void TheFilter::LoadFilter() {
//	fstream input_file;
//	input_file.open(FILTER_FILENAME, ios::in);
//	if (input_file.good()) {
//	input_file >>ValueFilter;
//	for (unsigned long i=0; i<ValueFilter; i++) {
//		input_file >>ValueFilter[i];
//	}
//	}
//	input_file.close();
//	cout <<"Filter loaded" <<endl;
}

void TheFilter::SaveFilter() const {
//	fstream output_file;
//	output_file.open(FILTER_FILENAME, ios::out)
//		if (output_file.good()) {
//		output_file <<ValueFilter <<endl <<endl;
//		for (unsigned long i=0; i<ValueFilter; i++) {
//			output_file <<  <<endl;
//		}
//	}
//	output_file.close();
//	cout <<"Filter saved" <<endl;
}
What are you trying to filter?
Topic archived. No new replies allowed.