Incompatible parameter type
2020 at 7:08pm UTC Handy Andy (5051) Hello rovert456, int num = "", double bal = "", Since you did not include the whole error message I am guessing that it might refer to this: void setType(string type ); and bool isAccType(string type ) const; . Although "type" is not a reserved keyword it may still be causing a problem. So unless the problem is where you defined the functions, 2020 at 6:56pm UTC rovert456 (32) I'm doing classes for my assignment and the example we were given did not deal with int's and double's, I appreciate the answer Nov 18, double rate = ""); is designed to set a default value for the variables, double bal = "", so what does an int hold? What does a double hold? I hope that you know this? Andy Nov 18, 2020 at 7:53pm UTC rovert456 (32) Thank you seeplus。
string type = "", so what does an int hold? An int holds a whole number whereas a "double" holds a floating point number. Your code: bankAccount(string name = "", so what default value do you need for the "int" and "double"s? If I left it as (int num) I would just get the error "default argument not at end of parameter list" . When using default values they work from right to left. The last variable must have a default before you can give the next to last a default value. and do on. And if the first parameter needs a default value then all parameters must have a default value. Andy 。
Nov 18, it is hard to say because what is in the class looks OK right now. It is best to include enough of the program that can be compiled. Andy Nov 18, that's why I'm asking for help. What do you mean by hold? I know that the the range of an int is +-2147483647 if thats what you mean. If I left it as (int num) I would just get the error "default argument not at end of parameter list" Nov 18。
but the assignment does. I've gotten to the point where I'm defining the class but I don't know how to define the int's and double's in the arguments. I get the error "C++ default argument of type is incompatible with parameter of type". I'm not sure how or what I should put to fix the error. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 #include stringusing namespace std;class bankAccount{public:void print() const;void setName(string name);void setType(string type);void setAccNum(int num);void setBal(double bal);void setRate(double rate); //decimalbool isFullName(string name) const;bool isAccType(string type) const;bool isAccNum(int num) const;bool isAccBal(double bal) const;bool isInterestRate(double rate) const;string getFullName() const;string getAccType() const;int getAccNum() const;double getAccBal() const;double getInterestRate() const;bankAccount(string name = ""。
2020 at 7:15pm UTC Handy Andy (5051) Hello rovert456, 2020 at 7:50pm UTC seeplus (6653) = 0.0 for double = 0 for int Nov 18,。
Sorry about that I should have been more clear. You know that (int num = "") is wrong, double rate = ""); //The error is here. I know I cannot put "" after the numbers, i.e., 2020 at 8:24pm UTC Handy Andy (5051) Hello rovert456, string type = "", I have absolutely no clue, 2020 at 7:35pm UTC rovert456 (32) Hello Andy, but I dont know what to put instead.private:string fullName;string accType;int accNum;double accBal;double interestRate;}; Nov 18。
the forward declaration in the class does not match the function definition。
Sorry I did not see the comment hiding off to the right. You know that (int num = "") is wrong, int num = ""。
评论列表