Question: 1. Please help me debug my program 2. How to create a makefile to link them together ? This is my account.cpp below //Main program
1. Please help me debug my program
2. How to create a makefile to link them together ?
This is my account.cpp below
//Main program main.cpp #include "Person.h" #include "Person.cpp" #include
using namespace std;
string trim_words(string sentence); vector
int main(int argc, char* argv[]) { stringstream ss; string s, sentence; //string out; string str,str1, fileName;
/*sample code, your code here*/
if (argc < 2) { cout <<"Usage: " << argv[0] << " input_file "; exit(0); } else fileName = argv[1];
vector } string trim_words(string s2) { stringstream ss; string s; string out; ss << s2; while (ss >> s) { out += (s + ' '); } return out.substr(0, out.length() - 1); } vector int printMenu() { cout<<"1. Search person's information based on name." " (enter person's name and will print out the information)" " for all the records that matches person's name) "; cout <<"2. Search person's Information based on presidency term. "; cout << "3. Search person's information based on political Party. "; cout << "4. Exit. "; cout<<">> "; int choice; cin >> choice; return choice; } This is my Person.cpp below #include "Person.h" Person::Person() { presidency = 0; birthYear = 1901; deceasedYear = 1901; name = ""; startDate = ""; endDate = ""; party = ""; } void Person::setPresidency(int presidencyNum) { presidency = presidencyNum; } void Person::setBirthYear(int birth) { birthYear = birth; } void Person::setDeceasedYear(int deceased) { deceasedYear = deceased; } void Person::setName(string presidentName) { name = presidentName; } void Person::setStartDate(string start) { startDate = start; } void Person::setEndDate(string end) { endDate = end; } void Person::setParty(string partyName) { party = partyName; } int Person::getPresidency() const { return presidency; } int Person::getBirthYear() const { return birthYear; } int Person::getDeceasedYear() const { return deceasedYear; } string Person::getName() const { return name; } string Person::getStartDate() const { return startDate; } string Person::getEndDate() const { return endDate; } string Person::getParty() const { return party; } bool Person::operator==(const string& personName) { return name == personName; } std::ostream & operator<<(std::ostream &os, const Person& p) { os << p.getName() << " ("< This is my Person.h below // Create header file Person.h with #include using namespace std; class Person { public: Person(); void setPresidency(int presidencyNum); void setBirthYear(int birth); void setDeceasedYear(int deceased); void setName(string presidentName); void setStartDate(string start); void setEndDate(string end); void setParty(string partyName); int getPresidency() const; int getBirthYear() const; int getDeceasedYear() const; string getName() const; string getStartDate() const; string getEndDate() const; string getParty() const; bool operator==(const string& personName); friend ostream & operator<<(ostream &os, const Person& p); private: int presidency, birthYear, deceasedYear; string name, startDate, endDate, party; }; This is my Printmefirst.h below #ifndef PRINTMEFIRST_H_ #define PRINTMEFIRST_H_ #include void printMeFirst(std::string name,std::string courseInfor); #endif This is my PrintMeFirst.cpp below #include /* Print out the programmer's information such as name, class information and dat/time when the program is run @param name- the name of the programmer @param couselnfor- the name of the course @return- none */ void printMeFirst(string name,string courseInfor) { cout<<"Program written by:"< Here is the US presidents list-txt information below: 1; George Washington; April 30, 1789 ; March 4, 1797 ; Independent; 1732; 1799 2; John Adams; March 4, 1797 ; March 4, 1801 ; Federalist; 1735; 1826 3; Thomas Jefferson; March 4, 1801 ; March 4, 1809 ; Democratic; 1743; 1826 4; James Madison; March 4, 1809 ; March 4, 1817 ; Democratic; 1751; 1836 5; James Monroe; March 4, 1817 ; March 4, 1825 ; Democratic; 1758; 1831 6; John Quincy Adams; March 4, 1825 ; March 4, 1829 ; Democratic; 1767; 1848 7; Andrew Jackson; March 4, 1829 ; March 4, 1837 ; Democratic; 1767; 1845 8; Martin Van Buren; March 4, 1837 ; March 4, 1841 ; Democratic; 1782; 1862 9; William Henry Harrison; March 4, 1841 ; April 4, 1841 ; Whig; 1773; 1841 10; John Tyler; April 4, 1841 ; March 4, 1845 ; Whig; 1790; 1862 11; James K. Polk; March 4, 1845 ; March 4, 1849 ; Democratic; 1795; 1849 12; Zachary Taylor; March 4, 1849 ; July 9, 1850 ; Whig; 1784; 1850 13; Millard Fillmore; July 9, 1850 ; March 4, 1853 ; Whig; 1800; 1874 14; Franklin Pierce; March 4, 1853 ; March 4, 1857 ; Democratic; 1804; 1869 15; James Buchanan; March 4, 1857 ; March 4, 1861 ; Democratic; 1791; 1838 16; Abraham Lincoln; March 4, 1861 ; April 15, 1865 ; Republican; 1809; 1865 17; Andrew Johnson; April 15, 1865 ; March 4, 1869 ; Democratic; 1808; 1875 18; Ulysses S. Grant; March 4, 1869 ; March 4, 1877 ; Republican; 1822; 1885 19; Rutherford B. Hayes; March 4, 1877 ; March 4, 1881 ; Republican; 1822; 1893 20; James A. Garfield; March 4, 1881 ; September 19, 1881 ; Republican; 1831; 1881 21; Chester A. Arthur; September 19, 1881 ; March 4, 1885 ; Republican; 1829; 1886 22; Grover Cleveland; March 4, 1885 ; March 4, 1889 ; Democratic; 1837; 1908 23; Benjamin Harrison; March 4, 1889 ; March 4, 1893 ; Republican; 1833; 1901 24; Grover Cleveland; March 4, 1893 ; March 4, 1897 ; Democratic; 1837; 1908 25; William McKinley; March 4, 1897 ; September 14, 1901 ; Republican; 1743; 1901 26; Theodore Roosevelt; September 14, 1901 ; March 4, 1909 ; Republican; 1858; 1919 27; William Howard Taft; March 4, 1909 ; March 4, 1913 ; Republican; 1857; 1930 28; Woodrow Wilson; March 4, 1913 ; March 4, 1921 ; Democratic; 1856; 1924 29; Warren G. Harding; March 4, 1921 ; August 2, 1923 ; Republican; 1865; 1923 30; Calvin Coolidge; August 2, 1923 ; March 4, 1929 ; Republican; 1872; 1933 31; Herbert Hoover; March 4, 1929 ; March 4, 1933 ; Republican; 1874; 1964 32; Franklin D. Roosevelt; March 4, 1933 ; April 12, 1945 ; Democratic; 1882; 1945 33; Harry S. Truman; April 12, 1945 ; January 20, 1953 ; Democratic; 1884; 1972 34; Dwight D. Eisenhower; January 20, 1953 ; January 20, 1961 ; Republican; 1890; 1969 35; John F. Kennedy; January 20, 1961 ; November 22, 1963 ; Democratic; 1917; 1963 36; Lyndon B. Johnson; November 22, 1963 ; January 20, 1969 ; Democratic; 1908; 1973 37; Richard Nixon; January 20, 1969 ; August 9, 1974 ; Republican; 1913; 1994 38; Gerald Ford; August 9, 1974 ; January 20, 1977 ; Republican; 1913; 2006 39; Jimmy Carter; January 20, 1977 ; January 20, 1981 ; Democratic; 1924; 0 40; Ronald Reagan; January 20, 1981 ; January 20, 1989 ; Republican; 1911; 2004 41; George H. W. Bush; January 20, 1989 ; January 20, 1993 ; Republican; 1924; 0 42; Bill Clinton; January 20, 1993 ; January 20, 2001 ; Democratic; 1946; 0 43; George W. Bush; January 20, 2001 ; January 20, 2009 ; Republican; 1946; 0 44; Barack Obama; January 20, 2009 ; January 20, 2017 ; Democratic; 1961; 0 45; Donald Trump; January 20, 2017 ; 0; Republican; 1946; 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
