Logo

EECS 280 Midterm Review Session - Shared screen with speaker view
Marina Liberati Ongaro
21:35
Where will we find the exam link
Jiacheng Xie
26:45
So return b = a means we assign a to b first and return b?
Jessica Cheng
27:29
will solutions to this worksheet be posted anywhere?
Marina Liberati Ongaro
30:40
Are these slides currently posted somewhere?
Chimmuanya Iheanyi-Igwe - IA
30:50
@Jessica Yes we will link them on piazza and they will also be added to the google drive where the original worksheet was
Chimmuanya Iheanyi-Igwe - IA
33:35
@Marina I believe these slides are in the google drive but here’s the link: https://docs.google.com/presentation/d/1aAi8yVaQ2uKG8_z9qbpjwJI3Ntq3JsoE1WR-gCW2CPk/edit#slide=id.p18
Philip Jianghao Lu
33:47
should I start at search.length() - 1
Jiacheng Xie
34:08
what does k mean here?
Philip Jianghao Lu
34:36
also could you start at search.length() - 1 - k and not use the counter variable?
Haiming Li
34:53
is the else branch necessary?
Jiacheng Xie
36:13
how to we know it's c style string or c++ style string when declaration?
Marina Liberati Ongaro
38:49
When are double ptrs useful/used
Yehya Abdelsamad Altamimi
43:06
Are you writing anything?
Chimmuanya Iheanyi-Igwe - IA
43:06
It depends on the context but usually it would be when we want to be very careful about how we’re working with objects and modifying memory. An example I can think of right now would be like if you have some container of pointers we don’t want to work with directly (that are also pointing to different objects we don’t want to touch directly), you could have a pointer to those pointers
Isaac A Madhavaram
43:06
I don’t think we can see what you are writing
Thomas Russell Fleisher
43:46
I see it
Anish Kothapalli
43:49
^
Nate Sochocki
44:31
Does it matter that the order of the pointers in the function is different? Like int *y = &x
Isaac A Madhavaram
44:58
Yeah
Thomas Russell Fleisher
45:00
yes
Yuhang Ning
47:31
shouldn’t y be changed?
Marina Liberati Ongaro
49:01
Would an & symbol be used if we were dereferencing those vars at the end
Marina Liberati Ongaro
49:06
For x++ and y--
Anish Kothapalli
49:19
What about the cout in the main?
Pak Yin Hung
49:25
Should we also have 21 7 for the last output
Chimmuanya Iheanyi-Igwe - IA
49:56
@Pak Yin Hung Yup!
Marina Liberati Ongaro
01:01:39
Should it be num_copies-1
Marina Liberati Ongaro
01:01:51
actually
Marina Liberati Ongaro
01:01:54
I think im wrong
Marina Liberati Ongaro
01:01:55
Bc its <
Jeremy Roszko
01:02:20
If we have an implementation that is different but still gives the correct result, is that ok?
Isabelle Meilan Miner
01:02:45
Can u explain why the second for loop does not have a <=?
Haiming Li
01:02:52
for (int i = size - 1 - num_copies; i >= 0; --i) {array[i + num_copies] = array[i];}
Clayton Andrew Walke Vanophem
01:02:52
3 < 3 is false
Haiming Li
01:03:01
does this looks like correct?
Haiming Li
01:03:15
for just shifting
Isabelle Meilan Miner
01:03:40
Ooh I see thank you
Chimmuanya Iheanyi-Igwe - IA
01:04:06
@Jeremy yup that’s fine, just double check to make sure your logic would work for some few test cases but for some these questions there could be multiple, slightly different answers
Anish Kothapalli
01:07:09
Dont you wanna point to the fifth element for the end?
Nishant Kothari
01:08:48
You want char * end to point the the kth element of the string which is str + (k - 1)
Rima Abdullah Abdulrahman
01:11:55
why ++end instead of —end?
Nishant Kothari
01:12:02
It would be —end
Rima Abdullah Abdulrahman
01:13:02
do we have to declare a start pointer or can we just use str?
Rima Abdullah Abdulrahman
01:14:31
okay thank you!
Marina Liberati Ongaro
01:16:33
Will we have open qs that require us to write structs
Nishant Kothari
01:16:52
Classes and Structs are both fair game for the exam
Sonika Amarish Potnis
01:20:05
When do we use new to declare objects?
Nishant Kothari
01:21:10
We use new to declare objects when we want to create those objects in dynamic memory. This is not a concept we will expect you to understand on the midterm (it’s on the final exam)
Anish Kothapalli
01:23:06
if class b did not have an implementation for boop, would b.boop() run the A base class’s version of boop even if its an abstract class?
Marina Liberati Ongaro
01:23:33
Why/ when are -> used
Marina Liberati Ongaro
01:23:43
Generally speaking
Nishant Kothari
01:24:02
Anish, yes it would, if a class does not have an implementation of a function we default to the parent class
Nishant Kothari
01:25:03
Marina, the -> is used after a pointer. The arrow operator is a combination of the dereference and the dot meaning that ptr->boop() and (*ptr).boop() are the same
Anish Kothapalli
01:25:22
Okay so a class still can have functions that work even if it is abstract?
Abhinav Thakur
01:26:05
shouldn't second last line be C dtor
Nishant Kothari
01:26:22
Yes, an abstract class can still have functions that are implemented.
Anish Kothapalli
01:26:31
Okay thank you!
Rima Abdullah Abdulrahman
01:27:04
the first destructor called is the last object created?
Nishant Kothari
01:27:06
Abhinav yes it should be, that’s a typo
Nishant Kothari
01:27:16
Rima, yes that is correct
Anish Kothapalli
01:30:46
What is the purpose of using virtual in lets say the shape example if rectangle.getArea() would already default to the rectangle’s version of that
Nishant Kothari
01:31:59
The purpose of using virtual in the Shape example is as follows: Imagine you have a Shape class and a Triangle class and Rectangle class that both inherit from Shape. If the Shape’s getArea() function is virtual, that means I can do something like this:
Nishant Kothari
01:32:13
Triangle t; Shape *ptr = &t
Nishant Kothari
01:32:24
Rectangle r; Shape *ptr2 = &r
Nishant Kothari
01:32:51
Vector<Shape*> vec; vec.push_back(ptr1); vec.push_back(ptr2)
Nishant Kothari
01:33:17
for(int I = 0; I < vec.size(); ++I) vec[I].getArea()
Haiming Li
01:34:00
Is the question in the review worksheet harder, easier, or the same as the real exam?
Nishant Kothari
01:34:11
Basically, virtual functions allow us to group all the child classes together under a pointer to the parent class and allows the compiler to delegate to the correct implementation
Anish Kothapalli
01:34:27
Awesome thank you so much!
Marina Liberati Ongaro
01:34:32
Thank u!
Jeanne Peijin Yang
01:34:41
Thank you!!
Marina Liberati Ongaro
01:35:21
Does the exam have multiple choice
Marina Liberati Ongaro
01:36:14
Also, Is there partial credit
Marina Liberati Ongaro
01:36:50
thanks
Jeremy Roszko
01:37:15
Since the exam will be online, will we have the ability to use our Compliers to see if the code we have written would run?
Jeremy Roszko
01:37:50
Ok, thank you!
Atharva Mandar Kulkarni
01:41:00
What is the difference between abstract classes and interfaces?
Atharva Mandar Kulkarni
01:42:21
Yeah that was what I meant
Atharva Mandar Kulkarni
01:42:24
Thank you!
Stephen Noah Barstys
01:42:38
What does it mean to return a variable by reference?
Stephen Noah Barstys
01:43:24
Thank you!