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

By: nascardriver

Hi Peter! 1. I don't think there is. The boost library has a feature to explicitly use a default parameter when calling a function. I like your first suggestions, but I don't like the second one. 2....

View Article


By: Peter Baum

Hi nascardriver, Regarding 2... if they had different default values maybe the compiler could point out the conflict.  That would take care of the redundancy too, because the programmer could use that...

View Article


By: Alex

This is a pretty common question. There's some conversation about this topic <a href="https://stackoverflow.com/questions/1123725/why-should-default-parameters-be-added-last-in-c-functions"...

View Article

By: nascardriver

@std::optional can be used, but you'd have to set the default value in the function body which isn't where default values should be located in my opinion. If there is a better way I'd love to know it....

View Article

By: Alex

I agree. I'm not aware of a way to solve this, but I'm also not that familiar with some of the C++17 stuff, so maybe someone who is knows of a good way to resolve.

View Article


By: ST.James

In the challenge section in lesson 6 (the blackjack game), we're almost sure that each time we call shuffleDeck, we will be passing in a deck of cards (&deck); how do we make "&deck" a default...

View Article

By: Alex

You can't. Default parameters must be compile-time constants, and deck is a variable.

View Article

By: magaji::hussaini

Hi alex I think a note should added that only copy initialisation work with default parameters because I got a compile time error when I tried uniform/direct initialisations. 12345 void printValues(int...

View Article

Browsing all 48 articles
Browse latest View live