Hi all.
can anyone help me correct errors in my code which is not running anymore and i dont really know why. If anyone can notice anything which shouldnt be in the code let me know please. I would really appreciate any sort of help.

Before writing your code you will need to think carefully about the following (HINT: these are hints!).

1 Decide on the classes you need. You should also be careful to include a set of classes that
implement the functionality of the code in such a way that they could be used by other
developers.

2. To establish suitable member functions, take into account the responsibilities of each class; for
example, which class should perform the filtering operation?

3. Encapsulation dictates that, as far as possible, an object should be responsible for its own data.
4. Use polymorphism only as appropriate. The general rule is that if an inbuilt operator matches
the purpose of a member function then it should be overloaded.

5. Use inheritance only where necessary. Only if you can reasonable say that object A is a type of
object B should A inherit from B. For example, a car is a type of vehicle, but a table isn’t a type
of elephant (even if both have four legs).

The following also forms part of the specification (for both the part B and part C modules).

1. The program must use an object-oriented approach; it must contain only member functions
(other than main() which should do no more than create the first object).

2. All members must be private.

3. Document properly the code you add. Don’t document every line of code - just the major
blocks of code (see the marking scheme).

4. The structure of your code should be neat and easy to follow.

#include <iostream>
using namespace std;

// ------CLASS DEFINITIONS------

class TheData 
{
public:	
	//public member functions							
	TheData(double* = 0, unsigned long = 0, bool = false);			
	~TheData();  //destructor function						

	void SetValue(double*, TheData&);
	void SetValue(unsigned long, TheData&);
	void SetValue( bool, TheData&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();

	void EnterData(TheData& OriginalData);				
	void DisplayData(TheData OriginalData, TheData FilteredData) const;	
private:
//private data							
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};

class TheFilter
{
public:

	TheFilter(double* = 0, unsigned long = 0, bool = false);		
	~TheFilter();						
	
	void EnterFilter(TheFilter& Filter);					

	void SetValue(double*, TheFilter&);
	void SetValue(unsigned long, TheFilter&);
	void SetValue(bool, TheFilter&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();

	int ApplyFilter(TheData OriginalData, TheFilter Filter, TheData& FilteredData);
	void DisplayData(TheFilter Filter) const;				
private:								
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};

/*class PrivateData : public TheData, public TheFilter
{
public:
	double* Values;											

					
	unsigned long Length;										

				
	bool Valid;	
};*/

enum {OK,FILTER_TOO_LONG};		// Function return values

// ------------MAIN------------

int main()
{
	// main() to create the first object only!
	//create an object of type TheData
	TheData OriginalData;		TheData FilteredData;		

					TheFilter Filter;
						

	//call the EnterData() and OriginalData accesor functions				
	OriginalData.EnterData;		OriginalData.DisplayData;	

										
	char UserInput;

	// loop until the user wishes to exit
	while (1) {
	    
		// show the menu of options
		cout << endl;
		cout << "Filter Menu" << endl;
		cout << "-----------" << endl;
		cout << "1. Enter data for filtering" << endl;
		cout << "2. Enter filter values" << endl;
		cout << "3. Apply filter" << endl;
		cout << "4. Display filtered data" << endl;
		cout << "5. Exit from the program" << endl << endl;
	    
		// get the user's choice
		cout << "Enter your option: ";
		cin >> UserInput;
		cout << endl;
	    
		// act on the user's input
		switch(UserInput) {
		case '1':
			OriginalData.EnterData(OriginalData);
			FilteredData.SetValue(false, OriginalData);		
			break;

		case '2':
			Filter.EnterFilter(Filter);
			FilteredData.SetValue(false, FilteredData);
			break;      
	 
		case '3':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true 

&& FilteredData.ShowValue_Valid() == false) 
			{
				if (Filter.ApplyFilter(OriginalData, Filter, FilteredData) == 

FILTER_TOO_LONG) 
				{
					cout << "The filter must not be longer than the data." << 

endl;
				}
				else 
				{
					FilteredData.SetValue(true, FilteredData);
					cout << "Filter applied." << endl;
				}
			}
			break;

		case '4':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true 

&& FilteredData.ShowValue_Valid() == true) 
			{
				OriginalData.DisplayData(OriginalData, FilteredData);
				Filter.DisplayData(Filter);
			}
			else 
			{
				cout << "Data have not yet been filtered" << endl;
			}
			break;

		case '5':
		/*delete [] Filter.Values;
			delete [] OriginalData.Values; UNSURE WHAT TO DO HERE!
			delete [] FilteredData.Values;*/					return 

0;
			break;

		default:
			cout << "Invalid entry" << endl << endl;
			break;
		}
	}
}

// --THEDATA MEMBER FUNCTIONS--

TheData::TheData(double*, unsigned long, bool)
{
	Values = 0;
	Length = 0;		
	Valid = false;						
}

TheData::~TheData()											

					// TheData destructor function
{
	/*delete[] OriginalData.Values;					
	delete[] OriginalData.Length;
	delete[] OriginalData.Valid;
													

								// Free memory
	delete[] FilteredData.Values;
	delete[] FilteredData.Length;
	delete[] FilteredData.Valid;*/
}

void TheData::EnterData(TheData& OriginalData)
{
	// initialize the data structure that holds the data to be filtered, including getting
	// the number of data values from the user
	delete[] OriginalData.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> OriginalData.Length;
	OriginalData.Valid = true;

	// allocate memory to the data
	OriginalData.Values = new double[OriginalData.Length];
	
	if (OriginalData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory." << endl;
		exit(1);
	}

	// obtain all of the data values
	cout << endl;
	cout << "Enter the data values" << endl;
	cout << "---------------------" << endl;
	
	for (unsigned long CountData = 0; CountData < OriginalData.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> OriginalData.Values[CountData];
	}
}

void TheData::DisplayData(TheData OriginalData, TheData FilteredData) const
{
	// display all of the input data values
	cout << endl;
	cout << "The input data values" << endl;
	cout << "---------------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < *OriginalData.Values; CountData++) 
	{
		//cout << OriginalData.SetValue(OriginalData.Values[CountData], OriginalData) << " ";
	}
	
	cout << "]" << endl;
	
	// display all of the data output values
	cout << endl;
	cout << "The data output values" << endl;
	cout << "----------------------" << endl;
	cout << "[ ";

	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		//cout << FilteredData.SetValue(FilteredData.Values[CountData], FilteredData) << " ";
	}
	cout << "]" << endl;
}

void TheData::SetValue(double* SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Values = SetValue;
}

void TheData::SetValue(unsigned long SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Length = SetValue;
}

void TheData::SetValue(bool SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Valid = SetValue;
}

double* TheData::ShowValue_Values()
{
return 0;
}

unsigned long TheData::ShowValue_Length()
{
return 0;
}

bool TheData::ShowValue_Valid()
{
return false;
}

// -THEFILTER MEMBER FUNCTIONS-

TheFilter::TheFilter(double*, unsigned long, bool)			
{
	Values = 0;		
	Length = 0;				
	Valid = false;	
}

TheFilter::~TheFilter()		
{
	// delete[] "something"?									

					// Free memory
}

void TheFilter::EnterFilter(TheFilter& Filter)
{
	// initialize the data structure that holds the filter, including getting the number of
	// filter values from the user
	delete [] Filter.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> Filter.Length;
	Filter.Valid = true;

	// allocate memory to the filter values
	Filter.Values = new double[Filter.Length];

	if (Filter.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// obtain all of the filter values
	cout << endl;
	cout << "Enter the filter values" << endl;
	cout << "-----------------------" << endl;

	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> Filter.Values[CountData];
	}
}

int TheFilter::ApplyFilter(TheData OriginalData, TheFilter Filter, TheData& FilteredData)
{
	// return an error if the filter is longer than the data
	if (Filter.Length > OriginalData.Length) return FILTER_TOO_LONG;
	
	// initialize the data structure that holds the filtered data
	delete[] FilteredData.Values;
	FilteredData.Length = OriginalData.Length - Filter.Length + 1;
	
	// get memory for the filtered data
	FilteredData.Values = new double[FilteredData.Length];
	
	if (FilteredData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// apply the filter to the data
	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		FilteredData.Values[CountData] = 0.0;
		
		for (unsigned long CountFilter = 0; CountFilter < Filter.Length; CountFilter++) 
		{
			FilteredData.Values[CountData] += OriginalData.Values[CountData + CountFilter] 

* Filter.Values[CountFilter];
		}
	}
	return OK;
} 

void TheFilter::DisplayData(TheFilter Filter) const
{
	// display all of the filter values
	cout << endl;
	cout << "The filter values" << endl;
	cout << "-----------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		//cout << Filter.SetValue(Filter.Values[CountData], Filter) << " ";
	}
	
	cout << "]" << endl;
}

void TheFilter::SetValue(double* SetValue, TheFilter& Filter)
{
	Filter.Values = SetValue;
	//cout << "Testing Values: " << Filter.Values << " = " << SetValue;	
}

void TheFilter::SetValue(unsigned long SetValue, TheFilter& Filter)
{
	Filter.Length = SetValue;
	//cout << "Testing Length: " << Filter.Length << " = " << SetValue;	
}

void TheFilter::SetValue(bool SetValue, TheFilter& Filter)
{
	Filter.Valid = SetValue;
	//cout << "Testing Valid: " << Filter.Valid << " = " << SetValue;	
}

double* TheFilter::ShowValue_Values()
{
	double* ShowValue;
	ShowValue = 0; //Filter.Values;	

	return ShowValue;
}

unsigned long TheFilter::ShowValue_Length()
{
	unsigned long ShowValue;
	ShowValue = 0; //Filter.Length;

	return ShowValue;
}

bool TheFilter::ShowValue_Valid()
{
	bool ShowValue;
	ShowValue = false; //Filter.Valid;

	return ShowValue;
}

Maybe you can start by giving us the basics...Does it compile error/waring free? If not which errors and warnings are generated? Is it a run time problem? If so what's the problem? We need more than 'is not running anymore'.

Maybe you can start by giving us the basics...Does it compile error/waring free? If not which errors and warnings are generated? Is it a run time problem? If so what's the problem? We need more than 'is not running anymore'.

Sorry for that. I am getting

>Build log was saved at "file://c:........"
1>task1 - 13 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
error C3867: 'TheData::EnterData': function call missing argument list; use '&TheData::EnterData' to create a pointer to member
error C3867: 'TheData::DisplayData': function call missing argument list; use '&TheData::DisplayData' to create a pointer to member
: error C2248: 'TheData::Length' : cannot access private member declared in class 'TheData'
:see declaration of 'TheData::Length'
: see declaration of 'TheData'
: error C2248: 'TheData::Values' : cannot access private member declared in class 'TheData'

Line 81 in your posted code, your calling two member functions but your not passing any arguments.

This

OriginalData.EnterData;		OriginalData.DisplayData;

Should be

OriginalData.EnterData(argument list);		OriginalData.DisplayData(argument list);

I tried compiling your code and got a few errors...here they are

g++ testit.cpp -Wall -ansi -pedantic -o testit
testit.cpp: In function ‘int main()’:
testit.cpp:81: error: statement cannot resolve address of overloaded function
testit.cpp:81: error: statement cannot resolve address of overloaded function
testit.cpp: In member function ‘void TheData::EnterData(TheData&)’:
testit.cpp:205: error: ‘exit’ was not declared in this scope
testit.cpp: In member function ‘void TheFilter::EnterFilter(TheFilter&)’:
testit.cpp:309: error: ‘exit’ was not declared in this scope
testit.cpp: In member function ‘int TheFilter::ApplyFilter(TheData, TheFilter, TheData&)’:
testit.cpp:26: error: ‘long unsigned int TheData::Length’ is private
testit.cpp:327: error: within this context
testit.cpp:25: error: ‘double* TheData::Values’ is private
testit.cpp:330: error: within this context
testit.cpp:26: error: ‘long unsigned int TheData::Length’ is private
testit.cpp:331: error: within this context
testit.cpp:26: error: ‘long unsigned int TheData::Length’ is private
testit.cpp:331: error: within this context
testit.cpp:25: error: ‘double* TheData::Values’ is private
testit.cpp:334: error: within this context
testit.cpp:26: error: ‘long unsigned int TheData::Length’ is private
testit.cpp:334: error: within this context
testit.cpp:25: error: ‘double* TheData::Values’ is private
testit.cpp:336: error: within this context
testit.cpp:339: error: ‘exit’ was not declared in this scope
testit.cpp:26: error: ‘long unsigned int TheData::Length’ is private
testit.cpp:343: error: within this context
testit.cpp:25: error: ‘double* TheData::Values’ is private
testit.cpp:345: error: within this context
testit.cpp:25: error: ‘double* TheData::Values’ is private
testit.cpp:349: error: within this context
testit.cpp:25: error: ‘double* TheData::Values’ is private
testit.cpp:349: error: within this context

Just curious, what did you change to generate so many errors?

Thanks for your effort in helping i really appreciate, however i have no idea why it gives me that many errors because the code does kind of make's sence in my own oppinion except i think most of the errors are from line 72-82 but dont know how to correct them or what is the proper way to call these functions. would really appreciate if u showed me this

Make the error corrections about arguement list and then compile and repost the errors and the new code here.

Make the error corrections about arguement list and then compile and repost the errors and the new code here.

#include <iostream>
using namespace std;

// ------CLASS DEFINITIONS------

class TheData 
{
public:								
	TheData(double* = 0, unsigned long = 0, bool = false);			
	~TheData();						

	void SetValue(double*, TheData&);
	void SetValue(unsigned long, TheData&);
	void SetValue(bool, TheData&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();

	void EnterData(TheData& OriginalData);				
	void DisplayData(TheData OriginalData, TheData FilteredData) const;	
private:							
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};

class TheFilter
{
public:
	TheFilter(double* = 0, unsigned long = 0, bool = false);		
	~TheFilter();						
	
	void EnterFilter(TheFilter& Filter);					

	void SetValue(double*, TheFilter&);
	void SetValue(unsigned long, TheFilter&);
	void SetValue(bool, TheFilter&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();

	int ApplyFilter(TheData OriginalData, TheFilter Filter, TheData& FilteredData);
	void DisplayData(TheFilter Filter) const;				
private:								
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};

/*class PrivateData : public TheData, public TheFilter
{
public:
	double* Values;																
	unsigned long Length;														
	bool Valid;	
};*/

enum {OK,FILTER_TOO_LONG};		// Function return values

// ------------MAIN------------

int main()
{
	// main() to create the first object only!
	TheData OriginalData;						TheData FilteredData;							TheFilter Filter;											
OriginalData.EnterData(TheData& OriginalData);		
OriginalData.DisplayData(TheData OriginalData, TheData FilteredData);											
	char UserInput;

	// loop until the user wishes to exit
	while (1) {
	    
		// show the menu of options
		cout << endl;
		cout << "Filter Menu" << endl;
		cout << "-----------" << endl;
		cout << "1. Enter data for filtering" << endl;
		cout << "2. Enter filter values" << endl;
		cout << "3. Apply filter" << endl;
		cout << "4. Display filtered data" << endl;
		cout << "5. Exit from the program" << endl << endl;
	    
		// get the user's choice
		cout << "Enter your option: ";
		cin >> UserInput;
		cout << endl;
	    
		// act on the user's input
		switch(UserInput) {
		case '1':
			OriginalData.EnterData(OriginalData);
			FilteredData.SetValue(false, OriginalData);		
			break;

		case '2':
			Filter.EnterFilter(Filter);
			FilteredData.SetValue(false, FilteredData);
			break;      
	 
		case '3':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true && FilteredData.ShowValue_Valid() == false) 
			{
				if (Filter.ApplyFilter(OriginalData, Filter, FilteredData) == FILTER_TOO_LONG) 
				{
					cout << "The filter must not be longer than the data." << endl;
				}
				else 
				{
					FilteredData.SetValue(true, FilteredData);
					cout << "Filter applied." << endl;
				}
			}
			break;

		case '4':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true && FilteredData.ShowValue_Valid() == true) 
			{
				OriginalData.DisplayData(OriginalData, FilteredData);
				Filter.DisplayData(Filter);
			}
			else 
			{
				cout << "Data have not yet been filtered" << endl;
			}
			break;

		case '5':
		/*delete [] Filter.Values;
			delete [] OriginalData.Values; UNSURE WHAT TO DO HERE!
			delete [] FilteredData.Values;*/					return 0;
			break;

		default:
			cout << "Invalid entry" << endl << endl;
			break;
		}
	}
}

// --THEDATA MEMBER FUNCTIONS--

TheData::TheData(double*, unsigned long, bool)
{
	Values = 0;
	Length = 0;		
	Valid = false;						
}

TheData::~TheData()																// TheData destructor function
{
	/*delete[] OriginalData.Values;					
	delete[] OriginalData.Length;
	delete[] OriginalData.Valid;
																					// Free memory
	delete[] FilteredData.Values;
	delete[] FilteredData.Length;
	delete[] FilteredData.Valid;*/
}

void TheData::EnterData(TheData& OriginalData)
{
	// initialize the data structure that holds the data to be filtered, including getting
	// the number of data values from the user
	delete[] OriginalData.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> OriginalData.Length;
	OriginalData.Valid = true;

	// allocate memory to the data
	OriginalData.Values = new double[OriginalData.Length];
	
	if (OriginalData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory." << endl;
		exit(1);
	}

	// obtain all of the data values
	cout << endl;
	cout << "Enter the data values" << endl;
	cout << "---------------------" << endl;
	
	for (unsigned long CountData = 0; CountData < OriginalData.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> OriginalData.Values[CountData];
	}
}

void TheData::DisplayData(TheData OriginalData, TheData FilteredData) const
{
	// display all of the input data values
	cout << endl;
	cout << "The input data values" << endl;
	cout << "---------------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < *OriginalData.Values; CountData++) 
	{
		//cout << OriginalData.SetValue(OriginalData.Values[CountData], OriginalData) << " ";
	}
	
	cout << "]" << endl;
	
	// display all of the data output values
	cout << endl;
	cout << "The data output values" << endl;
	cout << "----------------------" << endl;
	cout << "[ ";

	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		//cout << FilteredData.SetValue(FilteredData.Values[CountData], FilteredData) << " ";
	}
	cout << "]" << endl;
}

void TheData::SetValue(double* SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Values = SetValue;
}

void TheData::SetValue(unsigned long SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Length = SetValue;
}

void TheData::SetValue(bool SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Valid = SetValue;
}

double* TheData::ShowValue_Values()
{
return 0;
}

unsigned long TheData::ShowValue_Length()
{
return 0;
}

bool TheData::ShowValue_Valid()
{
return false;
}

// -THEFILTER MEMBER FUNCTIONS-

TheFilter::TheFilter(double*, unsigned long, bool)			
{
	Values = 0;		
	Length = 0;				
	Valid = false;	
}

TheFilter::~TheFilter()		
{
	// delete[] "something"?														// Free memory
}

void TheFilter::EnterFilter(TheFilter& Filter)
{
	// initialize the data structure that holds the filter, including getting the number of
	// filter values from the user
	delete [] Filter.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> Filter.Length;
	Filter.Valid = true;

	// allocate memory to the filter values
	Filter.Values = new double[Filter.Length];

	if (Filter.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// obtain all of the filter values
	cout << endl;
	cout << "Enter the filter values" << endl;
	cout << "-----------------------" << endl;

	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> Filter.Values[CountData];
	}
}

int TheFilter::ApplyFilter(TheData OriginalData, TheFilter Filter, TheData& FilteredData)
{
	// return an error if the filter is longer than the data
	if (Filter.Length > OriginalData.Length) return FILTER_TOO_LONG;
	
	// initialize the data structure that holds the filtered data
	delete[] FilteredData.Values;
	FilteredData.Length = OriginalData.Length - Filter.Length + 1;
	
	// get memory for the filtered data
	FilteredData.Values = new double[FilteredData.Length];
	
	if (FilteredData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// apply the filter to the data
	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		FilteredData.Values[CountData] = 0.0;
		
		for (unsigned long CountFilter = 0; CountFilter < Filter.Length; CountFilter++) 
		{
			FilteredData.Values[CountData] += OriginalData.Values[CountData + CountFilter] * Filter.Values[CountFilter];
		}
	}
	return OK;
} 

void TheFilter::DisplayData(TheFilter Filter) const
{
	// display all of the filter values
	cout << endl;
	cout << "The filter values" << endl;
	cout << "-----------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		//cout << Filter.SetValue(Filter.Values[CountData], Filter) << " ";
	}
	
	cout << "]" << endl;
}

void TheFilter::SetValue(double* SetValue, TheFilter& Filter)
{
	Filter.Values = SetValue;
	//cout << "Testing Values: " << Filter.Values << " = " << SetValue;	
}

void TheFilter::SetValue(unsigned long SetValue, TheFilter& Filter)
{
	Filter.Length = SetValue;
	//cout << "Testing Length: " << Filter.Length << " = " << SetValue;	
}

void TheFilter::SetValue(bool SetValue, TheFilter& Filter)
{
	Filter.Valid = SetValue;
	//cout << "Testing Valid: " << Filter.Valid << " = " << SetValue;	
}

double* TheFilter::ShowValue_Values()
{
	double* ShowValue;
	ShowValue = 0; //Filter.Values;	

	return ShowValue;
}

unsigned long TheFilter::ShowValue_Length()
{
	unsigned long ShowValue;
	ShowValue = 0; //Filter.Length;

	return ShowValue;
}

bool TheFilter::ShowValue_Valid()
{
	bool ShowValue;
	ShowValue = false; //Filter.Valid;

	return ShowValue;
}

They all seem quite similar but I have not got any idea how to solve them i have tried everything within my knowledge and cant resolve it.

The errors I get with this code are:


1>Compiling...
1>test2.cpp
1test2.cpp(68) : error C2275: 'TheData' : illegal use of this type as an expression
1> test2.cpp(7) : see declaration of 'TheData'
1>test2.cpp(69) : error C2275: 'TheData' : illegal use of this type as an expression
1> test2.cpp(7) : see declaration of 'TheData'
1test2.cpp(69) : error C2146: syntax error : missing ')' before identifier 'OriginalData'
1>test2.cpp(69) : error C2059: syntax error : ')'
1>test2.cpp(297) : error C2248: 'TheData::Length' : cannot access private member declared in class 'TheData'
1>\test2.cpp(24) : see declaration of 'TheData::Length'
1> test2.cpp(7) : see declaration of 'TheData'
1>test2.cpp(300) : error C2248: 'TheData::Values' : cannot access private member declared in class 'TheData'
1>\test2.cpp(23) : see declaration of 'TheData::Values'
1>\test2.cpp(7) : see declaration of 'TheData'
1>: error C2248: 'TheData::Length' : cannot access private member declared in class 'TheData'
1>\test2.cpp(24) : see declaration of 'TheData::Length'
1>test2.cpp(7) : see declaration of 'TheData'
: error C2248: 'TheData::Length' : cannot access private member declared in class 'TheData'
1>test2.cpp(24) : see declaration of 'TheData::Length'
1>test2.cpp(7) : see declaration of 'TheData'
test2.cpp(304) : error C2248: 'TheData::Values' : cannot access private member declared in class 'TheData'
1>test2.cpp(23) : see declaration of 'TheData::Values'
1>\test2.cpp(7) : see declaration of 'TheData'
1>\test2.cpp(304) : error C2248: 'TheData::Length' : cannot access private member declared in class 'TheData'
1>.cpp(24) : see declaration of 'TheData::Length'
1>.cpp(7) : see declaration of 'TheData'
1>\test2.cpp(306) : error C2248: 'TheData::Values' : cannot access private member declared in class 'TheData'
1>.cpp(23) : see declaration of 'TheData::Values'
1>.cpp(7) : see declaration of 'TheData'
1>'TheData'
1> : see declaration of 'TheData::Length'
1> : see declaration of 'TheData'
: error C2248: 'TheData::Values' : cannot access private member declared in class 'TheData'
1>: see declaration of 'TheData::Values'
1> : see declaration of 'TheData'
1>c:: error C2248: 'TheData::Values' : cannot access private member declared in class 'TheData'
1>) : see declaration of 'TheData::Values'
1>) : see declaration of 'TheData'
1>) : error C2248: 'TheData::Values' : cannot access private member declared in class 'TheData'
1> : see declaration of 'TheData::Values'
1> : see declaration of 'TheData'
1>Build log was saved at "file://c:\Users.....\Debug\BuildLog.htm"
1>test2 - 11 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

You do not need the datatypes when you make the calls in main() on lines 68 and 69, that is what the compiler is choking on. However, there is no need to pass the object into itself, as it already has access to the members and methods.

hi.
Thank you for your help i really appreciate because this has been causing me a few headache's. I have made the changes and removed lines68 and 68 as you instructed and i have also moved the

int ApplyFilter(TheData OriginalData,  TheFilter Filter, TheData& FilteredData);

to the TheData class and i am getting these errors.

1>------ Build started: Project: test2, Configuration: Debug Win32 ------
1>Compiling...
1>test2.cpp
1>test2.cpp(22) : error C2061: syntax error : identifier 'TheFilter'
1>test2.cpp(113) : error C2660: 'TheData::ApplyFilter' : function does not take 3 arguments
1>test2.cpp(315) : error C2511: 'int TheData::ApplyFilter(TheData,TheFilter,TheData &)' : overloaded member function not found in 'TheData'
1>test2.cpp(7) : see declaration of 'TheData'

1>test2 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

I am unsure how to fix these errors
And can anyone help with a code to make ApplyFilter() a member function of the TheData class accessing TheFilter's private members through the ShowValue and SetValue member functions. As you might have realised, my experience with objects is limited and I'm unsure if this is the best approach.

do u by any means know how i can resolve this please?

Please repost the code you are currently compiling.

Please repost the code you are currently compiling.

#include <iostream>
using namespace std;

// ------CLASS DEFINITIONS------

class TheData 
{
public:	
	//TheFilter::SetValue( int index, double value );
	 
	TheData(double* = 0, unsigned long = 0, bool = false);			
	~TheData();						

	void SetValue(double*, TheData&);
	void SetValue(unsigned long, TheData&);
	void SetValue(bool, TheData&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();

	int ApplyFilter(TheData OriginalData,  TheFilter Filter, TheData& FilteredData);
	void EnterData(TheData& OriginalData);				
	void DisplayData(TheData OriginalData, TheData FilteredData) const;	
private:							
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};

class TheFilter
{
public:
/*
double& operator[] (unsigned int Index) {return Values[Index];} 
const double& operator[] (unsigned int Index) const {return Values[Index];}
*/
	
	TheFilter(double* = 0, unsigned long = 0, bool = false);		
	~TheFilter();						

	void EnterFilter(TheFilter& Filter);					

	void SetValue(double*, TheFilter&);
	void SetValue(unsigned long, TheFilter&);
	void SetValue(bool, TheFilter&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();

	
	void DisplayData(TheFilter Filter) const;				
private:								
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};

/*class PrivateData : public TheData, public TheFilter
{
public:
	double* Values;																
	unsigned long Length;														
	bool Valid;	
};
*/
enum {OK,FILTER_TOO_LONG};		// Function return values

// ------------MAIN------------

int main()
{
	// main() to create the first object only!
	TheData OriginalData;		TheData FilteredData;		TheFilter Filter;											
//OriginalData.EnterData(8 5);		
//OriginalData.DisplayData(TheData OriginalData TheData FilteredData);											
	char UserInput;

	// loop until the user wishes to exit
	while (1) {
	    
		// show the menu of options
		cout << endl;
		cout << "Filter Menu" << endl;
		cout << "-----------" << endl;
		cout << "1. Enter data for filtering" << endl;
		cout << "2. Enter filter values" << endl;
		cout << "3. Apply filter" << endl;
		cout << "4. Display filtered data" << endl;
		cout << "5. Exit from the program" << endl << endl;
	    
		// get the user's choice
		cout << "Enter your option: ";
		cin >> UserInput;
		cout << endl;
	    
		// act on the user's input
		switch(UserInput) {
		case '1':
			OriginalData.EnterData(OriginalData);
			FilteredData.SetValue(false, OriginalData);		
			break;

		case '2':
			Filter.EnterFilter(Filter);
			FilteredData.SetValue(false, FilteredData);
			break;      
	 
		case '3':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true && FilteredData.ShowValue_Valid() == false) 
			{
				if (OriginalData.ApplyFilter(OriginalData, Filter , FilteredData) == FILTER_TOO_LONG) 
				{
					cout << "The filter must not be longer than the data." << endl;
				}
				else 
				{
					FilteredData.SetValue(true, FilteredData);
					cout << "Filter applied." << endl;
				}
			}
			break;

		case '4':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true && FilteredData.ShowValue_Valid() == true) 
			{
				OriginalData.DisplayData(OriginalData, FilteredData);
				Filter.DisplayData(Filter);
			}
			else 
			{
				cout << "Data have not yet been filtered" << endl;
			}
			break;

		case '5':
		/*delete [] Filter.Values;
			delete [] OriginalData.Values; //UNSURE WHAT TO DO HERE!
			delete [] FilteredData.Values;				return 0;
			break;*/

		default:
			cout << "Invalid entry" << endl << endl;
			break;
		}
	}
}

// --THEDATA MEMBER FUNCTIONS--

TheData::TheData(double*, unsigned long, bool)
{
	Values = 0;
	Length = 0;		
	Valid = false;						
}

TheData::~TheData()																// TheData destructor function
{
	/*delete[] OriginalData.Values;					
	delete[] OriginalData.Length;
	delete[] OriginalData.Valid;
																					// Free memory
	delete[] FilteredData.Values;
	delete[] FilteredData.Length;
	delete[] FilteredData.Valid;*/
}

void TheData::EnterData(TheData& OriginalData)
{
	// initialize the data structure that holds the data to be filtered, including getting
	// the number of data values from the user
	delete[] OriginalData.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> OriginalData.Length;
	OriginalData.Valid = true;

	// allocate memory to the data
	OriginalData.Values = new double[OriginalData.Length];
	
	if (OriginalData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory." << endl;
		exit(1);
	}

	// obtain all of the data values
	cout << endl;
	cout << "Enter the data values" << endl;
	cout << "---------------------" << endl;
	
	for (unsigned long CountData = 0; CountData < OriginalData.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> OriginalData.Values[CountData];
	}
}

void TheData::DisplayData(TheData OriginalData, TheData FilteredData) const
{
	// display all of the input data values
	cout << endl;
	cout << "The input data values" << endl;
	cout << "---------------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < *OriginalData.Values; CountData++) 
	{
		//cout << OriginalData.SetValue(OriginalData.Values[CountData], OriginalData) << " ";
	}
	
	cout << "]" << endl;
	
	// display all of the data output values
	cout << endl;
	cout << "The data output values" << endl;
	cout << "----------------------" << endl;
	cout << "[ ";

	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		//cout << FilteredData.SetValue(FilteredData.Values[CountData], FilteredData) << " ";
	}
	cout << "]" << endl;
}

void TheData::SetValue(double* SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Values = SetValue;
}

void TheData::SetValue(unsigned long SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Length = SetValue;
}

void TheData::SetValue(bool SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Valid = SetValue;
}

double* TheData::ShowValue_Values()
{
return 0;
}

unsigned long TheData::ShowValue_Length()
{
return 0;
}

bool TheData::ShowValue_Valid()
{
return false;
}

// -THEFILTER MEMBER FUNCTIONS-

TheFilter::TheFilter(double*, unsigned long, bool)			
{
	Values = 0;		
	Length = 0;				
	Valid = false;	
}

TheFilter::~TheFilter()		
{
	// delete[] "something"?														// Free memory
}

void TheFilter::EnterFilter(TheFilter& Filter)

{
	// initialize the data structure that holds the filter, including getting the number of
	// filter values from the user
	delete [] Filter.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> Filter.Length;
	Filter.Valid = true;

	// allocate memory to the filter values
	Filter.Values = new double[Filter.Length];

	if (Filter.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// obtain all of the filter values
	cout << endl;
	cout << "Enter the filter values" << endl;
	cout << "-----------------------" << endl;

	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> Filter.Values[CountData];
	}
}

int TheData::ApplyFilter(TheData OriginalData,TheFilter Filter, TheData& FilteredData)
//The foreign class should only be accessed by accessor methods. In other words, to access any data element of TheData, write member functions
//double TheData::ShowValue( int index );
//and
//TheFilter::SetValue( int index, double value );


	//void SetValue(double*, TheFilter&);
	//void SetValue(unsigned long, TheFilter&);
	//void SetValue(bool, TheFilter&)
	// return an error if the filter is longer than the data

{	
if (Filter.Length > OriginalData.Length) return FILTER_TOO_LONG;
	
	// initialize the data structure that holds the filtered data
	delete[] FilteredData.Values;
	FilteredData.Length = OriginalData.Length - Filter.Length + 1;
	
	// get memory for the filtered data
	FilteredData.Values = new double[FilteredData.Length];
	
	if (FilteredData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// apply the filter to the data
	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		FilteredData.Values[CountData] = 0.0;
		
		for (unsigned long CountFilter = 0; CountFilter < Filter.Length; CountFilter++) 
		{
			FilteredData.Values[CountData] += OriginalData.Values[CountData + CountFilter] * Filter.Values[CountFilter];
		}
	}
	return OK;
} 

void TheFilter::DisplayData(TheFilter Filter) const
{
	// display all of the filter values
	cout << endl;
	cout << "The filter values" << endl;
	cout << "-----------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		//cout << Filter.SetValue(Filter.Values[CountData], Filter) << " ";
	}
	
	cout << "]" << endl;
}

void TheFilter::SetValue(double* SetValue, TheFilter& Filter)
{
	Filter.Values = SetValue;
	//cout << "Testing Values: " << Filter.Values << " = " << SetValue;	
}

void TheFilter::SetValue(unsigned long SetValue, TheFilter& Filter)
{
	Filter.Length = SetValue;
	//cout << "Testing Length: " << Filter.Length << " = " << SetValue;	
}

void TheFilter::SetValue(bool SetValue, TheFilter& Filter)
{
	Filter.Valid = SetValue;
	//cout << "Testing Valid: " << Filter.Valid << " = " << SetValue;	
}

double* TheFilter::ShowValue_Values()
{
	double* ShowValue;
	ShowValue = 0; //Filter.Values;	

	return ShowValue;
}

unsigned long TheFilter::ShowValue_Length()
{
	unsigned long ShowValue;
	ShowValue = 0; //Filter.Length;

	return ShowValue;
}

bool TheFilter::ShowValue_Valid()
{
	bool ShowValue;
	ShowValue = false; //Filter.Valid;

	return ShowValue;
}

the errors are

1>------ Build started: Project: objects, Configuration: Debug Win32 ------
1>Compiling...
1>objects1.cpp
1>objects1.cpp(22) : error C2061: syntax error : identifier 'TheFilter'
1>objects1.cpp(113) : error C2660: 'TheData::ApplyFilter' : function does not take 3 arguments
1>c:objects1.cpp(315) : error C2511: 'int TheData::ApplyFilter(TheData,TheFilter,TheData &)' : overloaded member function not found in 'TheData'
1> \objects1.cpp(7) : see declaration of 'TheData'

1>objects - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Please repost the code you are currently compiling.

well it might help aswell if i give the code i am trying to convert

Before writing your code you will need to think carefully about the following (HINT: these are hints!).

1 Decide on the classes you need. You should also be careful to include a set of classes that
implement the functionality of the code in such a way that they could be used by other
developers.

2. To establish suitable member functions, take into account the responsibilities of each class; for
example, which class should perform the filtering operation?

3. Encapsulation dictates that, as far as possible, an object should be responsible for its own data.
4. Use polymorphism only as appropriate. The general rule is that if an inbuilt operator matches
the purpose of a member function then it should be overloaded.

5. Use inheritance only where necessary. Only if you can reasonable say that object A is a type of
object B should A inherit from B. For example, a car is a type of vehicle, but a table isn’t a type
of elephant (even if both have four legs).

The following also forms part of the specification (for both the part B and part C modules).

1. The program must use an object-oriented approach; it must contain only member functions
(other than main() which should do no more than create the first object).

2. All members must be private.

3. Document properly the code you add. Don’t document every line of code - just the major
blocks of code (see the marking scheme).

4. The structure of your code should be neat and easy to follow.

// Purpose
// A program to demonstrate the application of a simple digital filter
// 
// Overview
// A sequence of data items and digital filter values need to be entered by the
// user. The application of the filter to the data involves a simple convolution 
// operation. The filtered data are stored separately. 
//
// Example
//  before filtering: 
//   data_in = [0 1 3 6 3 1 0]
//   filter = [-0.5 1 -0.5]
//  after filtering:
//   data_out = [-0.5 -0.5 3 -0.5 -0.5]
//  where
//   data_out[0]=data_in[0]*filter[0]+data_in[1]*filter[1]+data_in[2]*filter[2]
//   data_out[1]=data_in[1]*filter[0]+data_in[2]*filter[1]+data_in[3]*filter[2]
//   data_out[2]=data_in[2]*filter[0]+data_in[3]*filter[1]+data_in[4]*filter[2]
//   data_out[3]=data_in[3]*filter[0]+data_in[4]*filter[1]+data_in[5]*filter[2]
//   data_out[4]=data_in[4]*filter[0]+data_in[5]*filter[1]+data_in[6]*filter[2]
//
// The program checks the following
// 1. The data and filter values must have been entered before the filter is 
//    applied
// 2. The filter is not applied if the number of filter values is greater than
//    the number of input data values
// 3. The data and filter values must have been entered and the filter applied 
//    before the filtered data can be displayed
#include <iostream>
using namespace std;
 
// the data values and the filter
struct TheFilter {
  double* Values;   // the filter values
  unsigned long Length;  // number of filter values
  bool Valid;   // true if the filter values have been Valid by the user
};

struct TheData {
  double* Values;  // holds the data to be filtered
  unsigned long Length;  // number of data values
  bool Valid;   // true if the data values have been Valid by the user
};

// function return values
enum {OK,FILTER_TOO_LONG};

// function prototypes
void EnterData(TheData&);
void EnterFilter(TheFilter&);
int ApplyFilter(TheFilter, TheData, TheData&);
void DisplayData(TheFilter, TheData, TheData);
 
// Control the principal operations of the program
// Arguments: None
// Returns: 0 on completion
int main()
{
  // define the filter and its initial values
  TheFilter Filter = {0,0,false};

  // define the original data and its initial values
  TheData OriginalData = {0,0,false};

  // define the filtered data and its initial values
  TheData FilteredData = {0,0,false};

  char UserInput;

  // loop until the user wishes to exit
  while (1) {
    
    // show the menu of options
    cout << endl;
    cout << "Filter Menu" << endl;
    cout << "-----------" << endl;
    cout << "1. Enter data for filtering" << endl;
    cout << "2. Enter filter values" << endl;
    cout << "3. Apply filter" << endl;
    cout << "4. Display filtered data" << endl;
    cout << "5. Exit from the program" << endl << endl;
    
    // get the user's choice
    cout << "Enter your option: ";
    cin >> UserInput;
    cout << endl;
    
    // act on the user's input
    switch(UserInput) {
      case '1':
        EnterData(OriginalData);
        FilteredData.Valid = false;
        break;

      case '2':
        EnterFilter(Filter);
        FilteredData.Valid = false;
        break;      
 
      case '3':
        if (Filter.Valid == true && OriginalData.Valid == true &&
            FilteredData.Valid == false) {
          if (ApplyFilter(Filter,OriginalData,FilteredData) == FILTER_TOO_LONG) {
             cout << "The filter must not be longer than the data" << endl;
          }
          else {
            FilteredData.Valid = true;
            cout << "Filter applied" << endl;
          }
        }
        break;

      case '4':
        if (Filter.Valid == true && OriginalData.Valid == true &&
            FilteredData.Valid == true) {
          DisplayData(Filter,OriginalData,FilteredData);
        }
	 else {
	    cout << "Data have not yet been filtered" << endl;
	 }
        break;

      case '5':
        delete [] Filter.Values;
        delete [] OriginalData.Values;
        delete [] FilteredData.Values;
        return 0;
        break;

      default:
        cout << "Invalid entry" << endl << endl;
        break;
    }
  }
}

// Allow the user to enter the data to be filtered
// Arguments:
//   (1) the structure containing the input data
// Returns: nothing
// 
void EnterData(TheData& GetData)
{  
  // initialize the data structure that holds the data to be filtered, including getting
  // the number of data values from the user
  delete [] GetData.Values;
  cout << "How many data values do you wish to enter: ";
  cin >> GetData.Length;
  GetData.Valid = true;

  // allocate memory to the data
  GetData.Values = new double[GetData.Length];
  if (GetData.Values == 0) {
    cout << "Unable to allocate sufficient memory" << endl;
    exit(1);
  }

  // obtain all of the data values
  cout << endl;
  cout << "Enter the data values" << endl;
  cout << "---------------------" << endl;
  for (unsigned long CountData = 0; CountData < GetData.Length; CountData++) {
    cout << "Enter value " << CountData+1 << ": ";
    cin >> GetData.Values[CountData];
  }
}

// Allow the user to enter the filter values
// Arguments:
//   (1) the structure of the filter to be defined
// Returns: nothing
// 
void EnterFilter(TheFilter& GetFilter)
{  
  // initialize the data structure that holds the filter, including getting the number of
  // filter values from the user
  delete [] GetFilter.Values;
  cout << "How many data values do you wish to enter: ";
  cin >> GetFilter.Length;
  GetFilter.Valid = true;

  // allocate memory to the filter values
  GetFilter.Values = new double[GetFilter.Length];
  if (GetFilter.Values == 0) {
    cout << "Unable to allocate sufficient memory" << endl;
    exit(1);
  }

  // obtain all of the filter values
  cout << endl;
  cout << "Enter the filter values" << endl;
  cout << "-----------------------" << endl;
  for (unsigned long CountData = 0; CountData < GetFilter.Length; CountData++) {
    cout << "Enter value " << CountData+1 << ": ";
    cin >> GetFilter.Values[CountData];
  }
}

// Apply the filter to the input data and store in the filtered data structure
// Arguments:
//   (1) the structure of the filter to be applied
//   (2) the structure containing the data to be filtered
//   (3) the structure to hold the filtered data
// Returns: OK - if the filter is applied
//          FILTER_TOO_LONG - the filter is longer than the data 
//  
int ApplyFilter(TheFilter Filter, TheData DataIn, TheData& DataOut)
{  
  // return an error if the filter is longer than the data
  if (Filter.Length > DataIn.Length) return FILTER_TOO_LONG;

  // initialize the data structure that holds the filtered data
  delete [] DataOut.Values;
  DataOut.Length = DataIn.Length - Filter.Length + 1;

  // get memory for the filtered data
  DataOut.Values = new double[DataOut.Length];
  if (DataOut.Values == 0) {
    cout << "Unable to allocate sufficient memory" << endl;
    exit(1);
  }

  // apply the filter to the data
  for (unsigned long CountData = 0; CountData < DataOut.Length; CountData++) {
    DataOut.Values[CountData] = 0.0; 
    for (unsigned long CountFilter = 0; CountFilter<Filter.Length; CountFilter++) {
      DataOut.Values[CountData] += DataIn.Values[CountData+CountFilter] *
                                   Filter.Values[CountFilter]; 
    }
  }

  return OK;
}


// Display input data, filter values and output data
// Arguments:
//   (1) the structure of the filter to be applied
//   (2) the structure containing the data to be filtered
//   (3) the structure that holds the filtered data
// Returns: nothing
// 
void DisplayData(TheFilter Filter, TheData DataIn, TheData DataOut)
{  
  // display all of the input data values
  cout << endl;
  cout << "The input data values" << endl;
  cout << "---------------------" << endl;
  cout << "[ ";
  for (unsigned long CountData = 0; CountData < DataIn.Length; CountData++) {
    cout << DataIn.Values[CountData] << " ";
  }
  cout << "]" << endl;
    
  // display all of the filter values
  cout << endl;
  cout << "The filter values" << endl;
  cout << "-----------------" << endl;
  cout << "[ ";
  for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) {
    cout << Filter.Values[CountData] << " ";
  }
  cout << "]" << endl;
    
  // display all of the data output values
  cout << endl;
  cout << "The data output values" << endl;
  cout << "----------------------" << endl;
  cout << "[ ";
  for (unsigned long CountData = 0; CountData < DataOut.Length; CountData++) {
    cout << DataOut.Values[CountData] << " ";
  }
  cout << "]" << endl;
}

Above line 6 in the OOP listing, you need to forward declare class TheFilter; so that the compiler knows that the class declaration is available later on.

You still need to rethink your design. Methods in theData shouldn't take a "TheData" object, as they already have access to it. I'd put your filter results as an additional private member of your TheData object. Have your TheData object take the filter as a parameter to the constructor.

This is not working code, but to give you an idea.

TheFilter myfilter;

TheData * timedata = new TheData(myfilter);

timedata.EnterData();  //this method takes in the data, so now timedata has it
timedata.ApplyFilter();
timedata.DisplayResults();

or if you prefer, have ApplyFilter() take the filter object. It's not necessary to pass the data into ApplyFilter as the timedata object already has it.

Above line 6 in the OOP listing, you need to forward declare class TheFilter; so that the compiler knows that the class declaration is available later on.

Thank you. I have made some corrections and it does compile but still having issues with the ApplyFilter. The code you wrote I understand it could be useful but am not sure how I could use that into this code and what else I would need to change, would be very helpful if it was actually inserted into the code. I am sorry if I am coming up as being lazy but I have been trying to do this for the past couple of weeks and i am really tired and stressed with it as it is due very soon. The code i currently have is :

#include <iostream>
using namespace std;

// ------CLASS DEFINITIONS------
class TheFilter;
class TheData 
{
public:	
	
	 
	TheData(double* = 0, unsigned long = 0, bool = false);			
	~TheData();						

	void SetValue(double*, TheData&);
	void SetValue(unsigned long, TheData&);
	void SetValue(bool, TheData&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();
	//int TheData::ApplyFilter( TheFilter &Filter )
	int ApplyFilter(TheData OriginalData,  TheFilter Filter, TheData& FilteredData);
	void EnterData(TheData& OriginalData);				
	void DisplayData(TheData OriginalData, TheData FilteredData) const;	
private:							
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};

class TheFilter
{
public:
/*
double& operator[] (unsigned int Index) {return Values[Index];} 
const double& operator[] (unsigned int Index) const {return Values[Index];}
*/
	
	TheFilter(double* = 0, unsigned long = 0, bool = false);		
	~TheFilter();						

	void EnterFilter(TheFilter& Filter);					

	void SetValue(double*, TheFilter&);
	void SetValue(unsigned long, TheFilter&);
	void SetValue(bool, TheFilter&);

	double* ShowValue_Values();
	unsigned long ShowValue_Length(); 
	bool ShowValue_Valid();

	
	void DisplayData(TheFilter Filter) const;				
private:
	friend class TheData;								
	double* Values;						
	unsigned long Length;						
	bool Valid;							
};



enum {OK,FILTER_TOO_LONG};		// Function return values

// ------------MAIN------------

int main()
{
	
	TheData OriginalData ;		
	TheData FilteredData ;		
	TheFilter Filter ;											
									
	char UserInput;

	// loop until the user wishes to exit
	while (1) {
	    
		// show the menu of options
		cout << endl;
		cout << "Filter Menu" << endl;
		cout << "-----------" << endl;
		cout << "1. Enter data for filtering" << endl;
		cout << "2. Enter filter values" << endl;
		cout << "3. Apply filter" << endl;
		cout << "4. Display filtered data" << endl;
		cout << "5. Exit from the program" << endl << endl;
	    
		// get the user's choice
		cout << "Enter your option: ";
		cin >> UserInput;
		cout << endl;
	    
		// act on the user's input
		switch(UserInput) {
		case '1':
			OriginalData.EnterData(OriginalData);
			FilteredData.SetValue(false, OriginalData);		
			break;

		case '2':
			Filter.EnterFilter(Filter);
			FilteredData.SetValue(false, FilteredData);
			break;      
	 
		case '3':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true && FilteredData.ShowValue_Valid() == false) 
			{
				if (OriginalData.ApplyFilter(OriginalData, Filter , FilteredData) == FILTER_TOO_LONG) 
				{
					cout << "The filter must not be longer than the data." << endl;
				}
				else 
				{
					FilteredData.SetValue(true, FilteredData);
					cout << "Filter applied." << endl;
				}
			}
			break;

		case '4':
			if (Filter.ShowValue_Valid() == true && OriginalData.ShowValue_Valid() == true && FilteredData.ShowValue_Valid() == true) 
			{
				OriginalData.DisplayData(OriginalData, FilteredData);
				Filter.DisplayData(Filter);
			}
			else 
			{
				cout << "Data have not yet been filtered" << endl;
			}
			break;

		case '5':
			/*	delete [] Filter.Values;
       				 delete [] OriginalData.Values;
       				 delete [] FilteredData.Values;
       				 return 0;
       				 break;
			*/
		default:
			cout << "Invalid entry" << endl << endl;
			break;
		}
	}
}

// --THEDATA MEMBER FUNCTIONS--

TheData::TheData(double*, unsigned long, bool)
{
	Values = 0;
	Length = 0;		
	Valid = false;						
}

TheData::~TheData()																// TheData destructor function
{
	/*delete[] OriginalData.Values;					
	*/
}

void TheData::EnterData(TheData& OriginalData)
{
	// initialize the data structure that holds the data to be filtered, including getting
	// the number of data values from the user
	delete[] OriginalData.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> OriginalData.Length;
	OriginalData.Valid = true;

	// allocate memory to the data
	OriginalData.Values = new double[OriginalData.Length];
	
	if (OriginalData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory." << endl;
		exit(1);
	}

	// obtain all of the data values
	cout << endl;
	cout << "Enter the data values" << endl;
	cout << "---------------------" << endl;
	
	for (unsigned long CountData = 0; CountData < OriginalData.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> OriginalData.Values[CountData];
	}
}

void TheData::DisplayData(TheData OriginalData, TheData FilteredData) const
{
	// display all of the input data values
	cout << endl;
	cout << "The input data values" << endl;
	cout << "---------------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < *OriginalData.Values; CountData++) 
	{
		//cout << OriginalData.SetValue(OriginalData.Values[CountData], OriginalData) << " ";
	}
	
	cout << "]" << endl;
	
	// display all of the data output values
	cout << endl;
	cout << "The data output values" << endl;
	cout << "----------------------" << endl;
	cout << "[ ";

	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		//
	}
	cout << "]" << endl;
}

void TheData::SetValue(double* SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Values = SetValue;
}

void TheData::SetValue(unsigned long SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Length = SetValue;
}

void TheData::SetValue(bool SetValue, TheData& Original_or_Filtered_Data)
{
	Original_or_Filtered_Data.Valid = SetValue;
}

double* TheData::ShowValue_Values()
{
return 0;
}

unsigned long TheData::ShowValue_Length()
{
return 0;
}

bool TheData::ShowValue_Valid()
{
return false;
}

// -THEFILTER MEMBER FUNCTIONS-

TheFilter::TheFilter(double*, unsigned long, bool)			
{
	Values = 0;		
	Length = 0;				
	Valid = false;	
}

TheFilter::~TheFilter()		
{
	// delete[] "something"?														// Free memory
}

void TheFilter::EnterFilter(TheFilter& Filter)

{
	// initialize the data structure that holds the filter, including getting the number of
	// filter values from the user
	delete [] Filter.Values;
	cout << "How many data values do you wish to enter: ";
	cin >> Filter.Length;
	Filter.Valid = true;

	// allocate memory to the filter values
	Filter.Values = new double[Filter.Length];

	if (Filter.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// obtain all of the filter values
	cout << endl;
	cout << "Enter the filter values" << endl;
	cout << "-----------------------" << endl;

	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		cout << "Enter value " << CountData + 1 << ": ";
		cin >> Filter.Values[CountData];
	}
}

int TheData::ApplyFilter(TheData OriginalData,TheFilter Filter, TheData& FilteredData)
//The foreign class should only be accessed by accessor methods. In other words, to access any data element of TheData, write member functions
//double TheData::ShowValue( int index );


{	
if (Filter.Length > OriginalData.Length) return FILTER_TOO_LONG;
	
	// initialize the data structure that holds the filtered data
	delete[] FilteredData.Values;
	FilteredData.Length = OriginalData.Length - Filter.Length + 1;
	
	// get memory for the filtered data
	FilteredData.Values = new double[FilteredData.Length];
	
	if (FilteredData.Values == 0) 
	{
		cout << "Unable to allocate sufficient memory" << endl;
		exit(1);
	}

	// apply the filter to the data
	for (unsigned long CountData = 0; CountData < FilteredData.Length; CountData++) 
	{
		FilteredData.Values[CountData] = 0.0;
		
		for (unsigned long CountFilter = 0; CountFilter < Filter.Length; CountFilter++) 
		{
			FilteredData.Values[CountData] += OriginalData.Values[CountData + CountFilter] * Filter.Values[CountFilter];
		}
	}
	return OK;
} 

void TheFilter::DisplayData(TheFilter Filter) const
{
	// display all of the filter values
	cout << endl;
	cout << "The filter values" << endl;
	cout << "-----------------" << endl;
	cout << "[ ";
	
	for (unsigned long CountData = 0; CountData < Filter.Length; CountData++) 
	{
		//cout << Filter.SetValue(Filter.Values[CountData], Filter) << " ";
	}
	
	cout << "]" << endl;
}

void TheFilter::SetValue(double* SetValue, TheFilter& Filter)
{
	Filter.Values = SetValue;
	
}

void TheFilter::SetValue(unsigned long SetValue, TheFilter& Filter)
{
	Filter.Length = SetValue;

}

void TheFilter::SetValue(bool SetValue, TheFilter& Filter)
{
	Filter.Valid = SetValue;
		
}

double* TheFilter::ShowValue_Values()
{
	double* ShowValue;
	ShowValue = 0; //Filter.Values;	

	return ShowValue;
}

unsigned long TheFilter::ShowValue_Length()
{
	unsigned long ShowValue;
	ShowValue = 0; //Filter.Length;

	return ShowValue;
}

bool TheFilter::ShowValue_Valid()
{
	bool ShowValue;
	ShowValue = false; //Filter.Valid;

	return ShowValue;
}

Explain to me on line 23 why you are passing in an object of TheData into that method.
When you instantiate a TheData object in main() (which is what I was showing in my last post), it already knows about the data it contains. You don't need to pass anything.

Explain to me on line 23 why you are passing in an object of TheData into that method.
When you instantiate a TheData object in main() (which is what I was showing in my last post), it already knows about the data it contains. You don't need to pass anything.

Hi. Thanks for helping
I mentioned earlier that I was not sure how I could use the code from your post into this and where i would put it or how i would appreciate a little more help on this. Another thing I was thinking of is if I make ApplyFilter() a method of the TheFilter class then it need only accept data of class, TheData (i.e. int ApplyFilter(TheData, TheData). Thus, I can reference the objects, OriginalData and FilteredData, individually but I have no clue how I can do this its just a thought... so maybe help on this too would be most appreciated. Sorry for me being not good at all @ this, iv only been doing c++ for about 4-5 months

The code that I had specified before would be in main().

ApplyFilter makes more sense (at least in my opinion) in the TheData class. Either make ApplyFilter take in a TheFilter object as a parameter (as I posited above) or have a TheFilter object as a private member of your TheData class. Make the FilteredData part of TheData as well. Everything is then contained within your object (see #3 of your assignment). You could make the classes friends, otherwise you will need accessor ("get") methods to access the private data in your filter object (I am not sure if your professor means make both the methods and members private, or just the members).

There's no need to be sorry, but the burden of coming up with examples from your text that exemplify some of these principles is on your shoulders. I've explained that if your class already has the information as private members, there's no need to pass those in as parameters to your methods.

An artificial example:

#include <iostream>
class Example
{
   private:
      int a;
   public:
      Example(int myA) {a = myA;}
      void Cubed() {std::cout<<a*a*a<<std::endl;}

};  

int main()
{
	Example ex(3);
	ex.Cubed();
}

If cubed were private and I had a friend class, I would still be able to access that method, but only from within the friend class. Note that there's no need to pass .Cubed() a parameter, the class already has the information.

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.