Logo

Programming Abstractions - Shared screen with speaker view
guanjie cheng
09:20
Active interactions
liang wang
09:24
By alphabet
Kyung-Su Kim
16:57
Can we change the argument of function in C++?
Abrar Alshaikh
17:22
what is the difference between getLine and cin >>
Nick Bowman (he/him)
17:49
They accomplish the same thing! But we choose to use getLine in this class for simplicity.
carson trail
17:54
If you don’t use void in that case, would it print out the result of printName and of the main?
Nick Bowman (he/him)
18:33
@Kyung-Su, yes you can provide any argument you want into a function, as long as it is the correct type.
Nick Bowman (he/him)
20:22
If you have more specific detailed questions about console input/output, we’ll be discussing all about console programs in lecture on Monday!
Ilies Ghanzouri
27:15
is "cout" like print in python?
Carl Schoeller
27:16
Would steps of two be I+2 or I+=2?
Nick Bowman (he/him)
27:37
@Ilies correct! similar purpose for using those
Nick Bowman (he/him)
27:48
@Carl Eithe works, you could do i = i + 2 or i += 2
Nick Bowman (he/him)
27:51
*either
Nicole Sussman
29:14
In general, after lecture are we able to use any breakout room to practice coding?
Kylie Jue (she/her)
29:20
https://edstem.org/us/courses/6471/workspaces/
Kylie Jue (she/her)
29:25
If there’s code there: Are there any bugs in the code? Try to think of another way to solve the problem (there are always multiple!).If there’s no code there: What code would you write to solve the problem?
Nick Bowman (he/him)
29:26
@Nicole yup!
Carl Schoeller
36:13
We set the return type of main to void and it still worked, is that an ed quirk?
Nick Bowman (he/him)
36:47
Handling of main can vary from compiler to compiler, so I’m not too surprised that it works, but yeah I would put it down the specific compiler used by Ed.
junqing li
37:59
Sorry I am not very clear, so we should not set Void main?
Nick Bowman (he/him)
38:19
The standard convention is to have main() return an int. We are going to stick with that convention in this class.
Abrar Alshaikh
38:44
what was the shortcut you used to comment multiple lines at once?
Nick Bowman (he/him)
38:59
On Macs I believe it is Cmd + /
Rhea Kumar
39:04
What’s the significance of the return 0 line?
Abrar Alshaikh
39:07
Thanks
Nick Bowman (he/him)
39:25
Returning 0 is a standard practice to indicate that the program completed successfully.
Preston Forst
39:38
How do we run the code on the breakout room templates
Rhea Kumar
39:45
Cool thanks!
Nick Bowman (he/him)
39:52
To run the code in Ed, open a terminal and type in “make run"
Nick Bowman (he/him)
39:56
And then hit enter
Carl Schoeller
49:05
So it only compares the first character?
Shalmali Bane (she/her)
49:13
So is that statement evaluated purely based on the alphabetic order of first letter only?
Nick Bowman (he/him)
49:32
Kylie will talk about this later but if the first characters are the same it will move on to compare the second characters and so on
James
49:59
when evaluating abc vs. bc, does C++ only evaluate to the number of characters in the shorter string?
Nick Bowman (he/him)
50:24
@James correct! If it runs out of characters to compare then the shorter string is considered to be the lesser of the two
James
50:38
Thanks!
guanjie cheng
50:43
What about B and a
Nick Bowman (he/him)
51:17
All uppercase letters in ASCII have smaller values than all lowercase letters in ASCII so ‘B’ < ‘a’
guanjie cheng
51:50
thanks
Abrar Alshaikh
51:51
can you add strings to characters?
Nick Bowman (he/him)
52:21
Yes! We saw an example in one of the polls where it is indeed legal to use + to concatenate a character to a string.
Abrar Alshaikh
52:35
i meant the other way around
cecile loge
52:45
ab < abc ?
cecile loge
52:54
(Making sure I heard right!)
Nick Bowman (he/him)
52:56
Yes, ab < abc!
cecile loge
53:03
Thx!!
Jin-Hee Catherine Lee
54:52
@Abrar: string s = “hello” + ‘o’; // s is still a string with a character added, all is well. However…
Jin-Hee Catherine Lee
55:01
char c = ‘c’ + “char”; // this would cause problems since adding a string to a char means that c is no longer of type char
Abrar Alshaikh
55:49
Thanks
mark benjamin
56:43
Is there a name for the “:” operator?
junqing li
56:58
So the name of char can be anything?
Nick Bowman (he/him)
57:15
Not exactly, we use ‘:’ in a couple of different ways in c++ so I don’t think it has an exact operator name
Jin-Hee Catherine Lee
57:20
@Junqing - yes, it’s just a variable name!
Carl Schoeller
57:25
Why is there a space between yours and nick’s name?
John Ren
57:58
if we have two operands a and b, where a is string and b is char, if we do a+b or a<b, is b promoted to a string type during the operation?
liang wang
58:36
Is big O the same of for and for-each loop?
Nick Bowman (he/him)
58:49
@John C++ won’t let you do that comparison
Nick Bowman (he/him)
58:57
The things that are part of the comparison have to be the same type
Nick Bowman (he/him)
59:07
(when it comes to string/char comparisons)
Nick Bowman (he/him)
59:23
automatic type conversion will generally only happen for things like int/double
Nick Bowman (he/him)
59:38
@Liang correct – we will discuss Big O in more detail in Week 3
Nick Bowman (he/him)
01:04:49
Please note the subtle distinction here with what we were doing earlier. In previous examples we were concatenating variables of type string, while here we are concatenating raw string literals.
Nick Bowman (he/him)
01:04:56
The former is allowed, while the latter is not!
Britney Tran
01:05:34
so a c++ string is one stored in a variable?
Nick Bowman (he/him)
01:06:45
The same goes for concatenations between characters and strings – using + to concatenate a variable of type string and a variable of type char is allowed and works regardless of the order (string + char or char + string). However, as we see in this example, you cannot use the + operator to ever add together a string literal and a character literal (in any order)
Jin-Hee Catherine Lee
01:07:02
This is an error I made from an earlier example — TLDR, don’t concatenate literals!
Nick Bowman (he/him)
01:07:03
@Britney correct! a C++ string is created when you store a literal (C string) into a variable of type string
Jin-Hee Catherine Lee
01:07:21
ded tests :(
Britney Tran
01:07:43
thank you!
James
01:09:06
is there any way to verify that our assignment 0 was actually submitted?
Nick Bowman (he/him)
01:09:44
@James if you submitted the form you should be all good to go
Nicole Sussman
01:10:22
Thank you!!!
Cyprien Fasquelle
01:10:23
Thank you!