Hello,
I really need to know why my program is not working at all. The entire error message says:
Can anyone help me? Here is all of my code. I have been looking at it for hours trying to figure out what is wrong.Code:Undefined first referenced symbol in file Personal::Personal(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, long)/var/tmp//cchaaWiZ.o ld: fatal: Symbol referencing errors. No output written to a.out collect2: ld returned 1 exit status
Code://Preprocessor Directives #include <iostream> #include <iomanip> #include <string> using namespace std; //Personal Class Declaration class Personal { private: string name; string address; int age; long phone; public: Personal(); Personal(string, string, int, long); void setName(string); void setAddress(string); void setAge(int); void setPhone(long); string getName(); string getAddress(); int getAge(); long getPhone(); }; //Class Implementation Personal::Personal() { name = " "; address = " "; age = 0; phone = 0; } //Set name function definition void Personal::setName(string pname) { name = pname; } //Set address function definition void Personal::setAddress(string paddress) { address = paddress; } //Set age function definition void Personal::setAge(int page) { if(page < 0) { cout << "Invalid, age must be a positive integer." << endl; } else age = page; } //Set phone function definition void Personal::setPhone(long pphone) { phone = pphone; } //Get name function definition string Personal::getName() { return name; } //Get address function definition string Personal::getAddress() { return address; } //Get age function definition int Personal::getAge() { return age; } //Get phone function definition long Personal::getPhone() { return phone; } //Client Program int main() { //Temp Variables string personalname; string personaladdress; int personalage; long personalphone; //Instantiate three Personal objects Personal ashley("Ashley", "313 State St.", 21, 3209986); Personal alex("Alex", "705 4th St.", 24, 3402257); Personal input; //Gathering user input for Populating instance input cout << "Please enter your name: " << endl; cin >> personalname; cout << "Please enter your address: " << endl; cin >> personaladdress; cout << "Please enter your age: " << endl; cin >> personalage; cout << "Please enter your phone number: " << endl; cin >> personalphone; //Populates class instance input through set functions input.setName(personalname); input.setAddress(personaladdress); input.setAge(personalage); input.setPhone(personalphone); //Display the data members in the three instances of object Personal cout << left; cout << "Object ashley's contents" << endl; cout << "--------------------------" << endl; cout << setw(20) << "Name: " << ashley.getName() << endl; cout << setw(20) << "Address: " << ashley.getAddress() << endl; cout << setw(20) << "Age: " << ashley.getAge() << endl; cout << setw(20) << "Phone Number: " << ashley.getPhone() << endl; cout << "--------------------------------------------" << endl; cout << "Object alex's contents" << endl; cout << "--------------------------" << endl; cout << setw(20) << "Name: " << alex.getName() << endl; cout << setw(20) << "Address: " << alex.getAddress() << endl; cout << setw(20) << "Age: " << alex.getAge() << endl; cout << setw(20) << "Phone Number: " << alex.getPhone() << endl; cout << "--------------------------------------------" << endl; cout << "Object input's contents" << endl; cout << "--------------------------" << endl; cout << setw(20) << "Name: " << input.getName() << endl; cout << setw(20) << "Address: " << input.getAddress() << endl; cout << setw(20) << "Age: " << input.getAge() << endl; cout << setw(20) << "Phone Number: " << input.getPhone() << endl; cout << "--------------------------------------------" << endl; return 0; }



LinkBack URL
About LinkBacks


