Question: 1)I have my code in 3 different files------- header (Filt.hpp), Source file (Filt.cpp) and main file (main.cpp). I am unsure why the code in my

1)I have my code in 3 different files------- header (Filt.hpp), Source file (Filt.cpp) and main file (main.cpp). I am unsure why the code in my main file is giving me the error "use of unDeclared Identifier" when my functions are called. I have function declarations in my header file and imported them to the main file via (#include "Filter.hpp") and my code only works if I type out the function declarations into the main file, not when I import it from the .cpp file. Can you please help me with this error.

Main file-------

* main.cpp * */

#include #include #include #include "Filter.hpp" using namespace std;

int main() {

cout <<" Problem 1 &2 ********************* ";

//Test case 1 int x = 1; int low = 0, high = 5;

int *array = FillArrRecursive(&x,&low,&high);

cout << "Array after using FillArrRecursive function with low of 0 high of 5: "; for (int i = 0; i < sizeof(array); ++i) { cout << *(array+i) << " "; }

cout << endl; cout<<" ";

int *newarr = FillArr(&x,&low,&high);

cout << "Array after using FillArr function: "; for (int i = 0; i < sizeof(newarr); ++i) { cout << *(newarr+i) << " "; }

cout << endl;

//Test Case 2

int x_ = 5; int low_ = 0, high_ = 10;

int *array_ = FillArrRecursive(&x_,&low_,&high);

cout << "Array after using FillArrRecursive function with low of 0, high of 10: "; for (int i = 0; i < sizeof(array_); ++i) { cout << *(array_+i) << " "; }

cout << endl; cout<<" ";

int *newarr_ = FillArr(&x,&low_,&high);

cout << "Array after using FillArr function: "; for (int i = 0; i < sizeof(newarr_); ++i) { cout << *(newarr_+i) << " "; }

cout << endl;

cout<<" "; cout <<" Problem 3********************* ";

//Problem 3

//Test 1 int arr3[10] = {1,2,3,4,5,6,7,8,9,10}; printArray(arr3,10); cout<<" ";

//Test 2 int arr3_[8] = {1,3,2,5,5,6,6,8}; printArray(arr3_,10); cout<<" ";

//Test 3 int arr3__[3] = {4,3,2}; printArray(arr3__,10);

cout<<" "; cout <<" Problem 4 and 5*********************"; //Problem 4 & 5

int *arr, *ham_arr, *temp, n, i, j, flag, s=5, k=0, p; cout<<" "; cout<<"Enter the size of array->"; cin>>n;

arr = new int[n]; temp = new int[5]; ham_arr = new int[n];

cout<<"Enter elements in array:- "; for(i=0;i cin>>arr[i]; ham_arr[i] = 0; } p = s/2; for(i=0;i int x=0; for(j=k;j temp[x] = arr[j]; } flag = hamming_window(temp,s); ham_arr[p] = flag; p++; k++; } cout<<" "; cout<<" Result after hamming Window filter:- "; for(i=0;i cout<

cout<<" "; cout <<" Problem 6********************* ";

//Problem 6 int arr6[50], high6, low6; //get user inputs cout << "Enter length of the array: " ; cin >> n;

cout << " Enter highest value: "; cin >> high6;

cout << " Enter lowest value: "; cin >> low6;

//generate random array using random function for(int i=0;i arr[i]= low6 + rand() % (high6 - low6); }

cout<< " Random Array generated: "<

for(int i=0;i cout<

graph_array(arr,n,high6,low6);

return 0;// end of main tests }

Header file------------

/* * Filter.hpp * */

//#ifndef FILTER_HPP_ //#define FILTER_HPP_

class Filt{

public: void printArray(int arr[] , int size); int * FillArr(int *n, int *low, int *high); void fill(int *arr, int l, int h); int * FillArrRecursive(int *n, int *low, int *high); int hamming_window(int *a, int w); void graph_array(int arr[], int n, int high, int low);

int x_ ; int low_; int high_; int x; int low; int high; int arr3_[8]; int arr3__[3]; int arr6[50]; int high6; int low6; int h; int l; int r; int i; int m; int total=0; int array;

};

//#endif /* FILTER_HPP_ */

Source File-------------------------

* Filter.cpp * */

#include #include #include #include "Filter.hpp" using namespace std;

//Problem 1

int * Filt::FillArr(int *x, int *low, int *high){ int r = rand()%50 + 25; int *arr = new int[r];

int h = rand()%(*high) + (*low); int l = -1*(rand()%(*high)) - (*low);

for(int i=l;i<=h;++i){ arr[i] = rand()%100; }

return arr;

} void Filt::fill(int *arr, int len, int h){

if(len==h) return;

fill(arr, len+1,h); }

//Problem 2 int * Filt::FillArrRecursive(int *x, int *low, int *high){ int r = rand()%50 + 25; int *arr = new int[r];

int h = rand()%(*high) + *low; int l = -1*(rand()%(*high)) - *low;

fill(arr, l, h);

return arr;

}

//Problem 3

void Filt::printArray(int arr[] , int size){ for(int i=0;i cout< } }

//Problem 4 and 5

int Filt::hamming_window(int *a, int z){

int i,r,m,total=0; r=z-1; m=1; for(i=0;i total = total + ((a[i]*m)+ (a[r]*m)); m++; r--; } total = total + (a[i] * m); total = total/9;

return total; }

//Problem 6

void Filt::graph_array(int arr6[], int n, int high, int low){

while(high>=low){ cout< for(int i=0;i if(arr6[i]==high){ for(int j=0;j cout<<" "; } cout<<"*";

} }

high--; cout<

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!