
21:35
Where will we find the exam link

26:45
So return b = a means we assign a to b first and return b?

27:29
will solutions to this worksheet be posted anywhere?

30:40
Are these slides currently posted somewhere?

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

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

33:47
should I start at search.length() - 1

34:08
what does k mean here?

34:36
also could you start at search.length() - 1 - k and not use the counter variable?

34:53
is the else branch necessary?

36:13
how to we know it's c style string or c++ style string when declaration?

38:49
When are double ptrs useful/used

43:06
Are you writing anything?

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

43:06
I don’t think we can see what you are writing

43:46
I see it

43:49
^

44:31
Does it matter that the order of the pointers in the function is different? Like int *y = &x

44:58
Yeah

45:00
yes

47:31
shouldn’t y be changed?

49:01
Would an & symbol be used if we were dereferencing those vars at the end

49:06
For x++ and y--

49:19
What about the cout in the main?

49:25
Should we also have 21 7 for the last output

49:56
@Pak Yin Hung Yup!

01:01:39
Should it be num_copies-1

01:01:51
actually

01:01:54
I think im wrong

01:01:55
Bc its <

01:02:20
If we have an implementation that is different but still gives the correct result, is that ok?

01:02:45
Can u explain why the second for loop does not have a <=?

01:02:52
for (int i = size - 1 - num_copies; i >= 0; --i) {array[i + num_copies] = array[i];}

01:02:52
3 < 3 is false

01:03:01
does this looks like correct?

01:03:15
for just shifting

01:03:40
Ooh I see thank you

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

01:07:09
Dont you wanna point to the fifth element for the end?

01:08:48
You want char * end to point the the kth element of the string which is str + (k - 1)

01:11:55
why ++end instead of —end?

01:12:02
It would be —end

01:13:02
do we have to declare a start pointer or can we just use str?

01:14:31
okay thank you!

01:16:33
Will we have open qs that require us to write structs

01:16:52
Classes and Structs are both fair game for the exam

01:20:05
When do we use new to declare objects?

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)

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?

01:23:33
Why/ when are -> used

01:23:43
Generally speaking

01:24:02
Anish, yes it would, if a class does not have an implementation of a function we default to the parent class

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

01:25:22
Okay so a class still can have functions that work even if it is abstract?

01:26:05
shouldn't second last line be C dtor

01:26:22
Yes, an abstract class can still have functions that are implemented.

01:26:31
Okay thank you!

01:27:04
the first destructor called is the last object created?

01:27:06
Abhinav yes it should be, that’s a typo

01:27:16
Rima, yes that is correct

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

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:

01:32:13
Triangle t; Shape *ptr = &t

01:32:24
Rectangle r; Shape *ptr2 = &r

01:32:51
Vector<Shape*> vec; vec.push_back(ptr1); vec.push_back(ptr2)

01:33:17
for(int I = 0; I < vec.size(); ++I) vec[I].getArea()

01:34:00
Is the question in the review worksheet harder, easier, or the same as the real exam?

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

01:34:27
Awesome thank you so much!

01:34:32
Thank u!

01:34:41
Thank you!!

01:35:21
Does the exam have multiple choice

01:36:14
Also, Is there partial credit

01:36:50
thanks

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?

01:37:50
Ok, thank you!

01:41:00
What is the difference between abstract classes and interfaces?

01:42:21
Yeah that was what I meant

01:42:24
Thank you!

01:42:38
What does it mean to return a variable by reference?

01:43:24
Thank you!