I cannot seem to initialize my constructor with default parameters. Could anyone give me a good explanation as to why this is happening?
Code:#include <cstdlib> #include <iostream> #include <string> using namespace std; class secretType { public: void print() const; void setName(); void setAge(); void setWeight(); void setHeight(); string getName() const; int getAge() const; int getWeight() const; double getHeight() const; secretType secretType(string = " ", int = 0, int = 0, double = 0); private: string name; int age; int weight; double height; }; int main(int argc, char *argv[]) { secretType yourName; yourName.setName(); yourName.setAge(); yourName.setWeight(); yourName.setHeight(); yourName.getName(); yourName.print(); system("PAUSE"); return EXIT_SUCCESS; } // FUNCTION DEFINITIONS // function to set name. void secretType:: setName() { cout << "enter your name: "; cin >> name; } // function to set age. void secretType::setAge() { cout << "enter your age: "; cin >> age; } // function to set weight. void secretType:: setWeight() { cout << "enter your weight: "; cin >> weight; } // function to set height. void secretType::setHeight() { cout << "enter your height in decimal format(0ft.0in): "; cin >> height; } // function to return name. string secretType:: getName()const { return name; } // function to return age. int secretType:: getAge() const { return age; } // function to return weight. int secretType:: getWeight() const { return weight; } // function to return height. double secretType:: getHeight() const { return height; } // function to print name. void secretType:: print() const { cout << "name: " << name << " age: " << age << " weight: " << weight << " height: " << height << endl; }



LinkBack URL
About LinkBacks



CornedBee