Quantcast
Channel: Comments on: 7.7 — Default parameters
Browsing all 48 articles
Browse latest View live

By: Ericc

u forgot ; in the Prototype

View Article


By: simon1122

//Function #include using namespace std; void printvalues(int nvalue1, int nvalue2=10 ); int main() { printvalues(1); printvalues(1,3); /*scaffolding code for testing purpose*/ cin.ignore(256, ‘\n’);...

View Article


By: simon1122

hi can any one tell me what is wrong with this one?? thak you

View Article

By: Anshuman

you must not use specify the default value both in function prototype and definition void printvalues(int nvalue1, int nvalue2) { cout<<"1st : "<< nvalue1<< endl; cout<<"2st :...

View Article

By: dave

I must say this site is awesome and clean looking..specially how the code is displayed….looks neat! keep up good work and i am doing last min craming when i googled default params…so wish me luck! :)

View Article


By: otocan

Hi Alex Shouldn’t all the examples of pointers to chars in this chapter e.g. char *strValue be instead char *pszValue? Cheers Kevin

View Article

By: Sphingine

Can i give d definition as: void printvalues(int nvalue1=0, int nvalue2=2) { cout<<"1st : "<< nvalue1<< endl; cout<<"2st : "<< nvalue2<< endl; } and call the...

View Article

By: zingmars

No you can’t.

View Article


By: assignment operator within function parameter C++ | PHP Developer Resource

[...] are not assignment operators. Those are default parameters for the [...]

View Article


By: pointers

[...] [...]

View Article

By: kekie

Shouldn’t they be called ‘Default arguments’?

View Article

By: Avneet

Alex, is there any way to forward declare a function that has default pararmeters in it…? [code] #include <iostream> void val(int, int); int main() {     int value = 10;     val(value);...

View Article

By: Alex

Put the default parameter in the forward declaration: 1234567891011121314 void val(int, int = 20); int main(){ int value = 10; val(value); return 0;} void val(int nval, int val2){ std::cout <<...

View Article


By: Alex

They often are.

View Article

By: Jim

Alex, This code uses the same name and parameters except one has a capital V and the other uses a lower case v. Why wouldn’t the compiler catch this? Or is this a typo? [code] void printvalues(int x,...

View Article


By: Alex

Typo. It’s fixed now, thanks for noticing.

View Article

By: Kattencrack Kledge

Little typo on one of the function prototypes: 1 int rollDie(int sides=6); I’m pretty sure you meant rollDice than rollDie XD

View Article


By: Alex

Nope. Die is actually the singular of dice, and in this case, we are just rolling one die, not multiple dice. Though enough people don’t know this that I suspect it will be acceptable to use dice in...

View Article

By: Matt

At the end of section "Default parameters can only be declared once", you wrote: "Rule: If the function has a forward declaration, put the default parameters there. Otherwise, put them on the function...

View Article

By: Alex

Definitely “in”. You’d think I didn’t proofread this stuff. I guess I just must be horrible at it. 🙂

View Article
Browsing all 48 articles
Browse latest View live