#include <iostream> #include <string> using namespace std; class personType { public: void print() const; void setName(string first, string last); string getFirstName() const; string getLastName() ; // const is removed from here. !! personType(string first, string last); personType(); private: string firstName, lastName; }; void personType::print() const { cout << firstName << " " << lastName; } void personType::setName(string first, string last) { firstName = first; lastName = last; } string personType::getFirstName() const { return firstName; } string personType::getLastName() { return lastName; } // Here Comes The Constructor Turn personType::personType(string first, string last) { firstName = first; lastName = last; } int main() { personType p; p.setName("Nerdy", "Usman"); p.print(); cout << p.getLastName(); // What The heck. ?! system("pause"); return 0; }
personType::personType() { }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)