[Cs3] CS3 questions

Mikhail Nesterenko mikhail at cs.kent.edu
Wed Mar 2 15:04:07 EST 2022


Mitchell Stemm wrote:
> 1.what will happen with the example code we looked at today if the
> accumulate function has a container of bool and no callback. will it imply
> bool + bool as addition or as an OR operator

Here is the situation. It is legal to use a plus operator on
boolean. The C/C++ concept is called "type promotion". The rules are
complicated but intuitively, if the type is smaller, it is promoted to
integer. So if we have:

	bool i=true, j = false

	the expression
         i+j

is of type integer and its value is 1.

Here is a bit more on this: https://stackoverflow.com/questions/17179287/adding-two-bool-values-in-c-c


> 2.slide 17 attempts to name a variable pair witch would not compile if
> <pair> is imported.

fixed. Thanks!

Good luck to everyone on tomorrow's midterm.
-- 
Mikhail


More information about the cs3 mailing list