Question: *****FIND OUT WHY IN C++ THE INPUT BELOW IS NOT WORKING WITH MY CPP AND HPP FILES GIVEN **************************** Here is the input case for
*****FIND OUT WHY IN C++ THE INPUT BELOW IS NOT WORKING WITH MY CPP AND HPP FILES GIVEN ****************************
Here is the input case for my files : #include "Person.cpp" #include const double EPS = 0.00001; Person a("alice", 92); Person b("bernice", 77); Person array[] = {a,b}; double result = stdDev(array, 2); ASSERT_TRUE(fabs(result-7.5) < EPS); **********************Below are my separate CPP and HPP files for the function. When i use my own main the function works but the above input does not. thoughts? --------------------------------Person.hpp---------------------------- #ifndef MY_PERSON # define MY_PERSON #include using namespace std; class Person { int age; string name; public: // constructor Person(); // constructor Person(string, int); // getter methods string getName(); int getAge(); }; #endif ---------------------------------------------------Peron.cpp-------------------------------------------------------------- #include "Person.hpp" // constructor Person::Person() { name = ""; age = 0; } // constructor Person::Person(string n, int a) { name = n; age = a; } // getter methods string Person::getName() { return name; } int Person::getAge() { return age; } -------------------------------------------------stdDev.cpp----------------------------------------------- #include "Person.cpp" #include double stdDev(Person arr[], int n) { double mean = 0.0, sum = 0.0; int i; // get the total of age of all person for( i = 0 ; i < n ; i++ ) { sum += (double)arr[i].getAge(); } // calculate mean mean = sum / (double)n; double temp_sum = 0.0; for( i = 0 ; i < n ; i++ ) { temp_sum += pow(arr[i].getAge() - mean, 2); } // calculate standard deviation double sd = sqrt(temp_sum / (double)(n - 1)); return sd; } -----------------------------------------------------main.cpp--------------------------------------------------------- #include "stdDev.cpp" int main() { Person *arr = new Person[6]; arr[0] = Person("Monica Geller", 28); arr[1] = Person("Chandler Bing", 32); arr[2] = Person("Ross Geller", 38); arr[3] = Person("Rachel Green", 23); arr[4] = Person("Joeseph Tribianni", 42); arr[5] = Person("Phoebe Buffay", 17); double sd = stdDev(arr, 6); cout<<"Standard Deviation : "<