I have a simple question from a class of mine on dynamic arrays.
When allocating an array of objects, what constructor is used to initialize all of the objects in the array?
A. The automatic copy constructor
B. The constructor specified at the declaration
C. The default constructor
D. None of the above
What are your thoughts on this question?
I was learning towards B, but then I wasn't sure.
Alright, I have another one that I'm kinda stuck on
Which situation does not use the copy constructor?
A. Calling a function with a reference parameter
B. Calling a function with a value parameter
C. Declaring a variable to be a copy of another existing object
D. Returning a value from a function
E. All of the above situations use the copy constructor
I'm thinking that it is E, but I didn't know whether a value parameter is copied or not
When allocating an array of objects, the default constructor is used.
As for the last question, the copy constructor is not used when passing by reference.
Alright, this one is really stumping me
What is the usual worst-case performance for resizing a container class that stores its data in a dynamic array?
A. Constant Time
B. Logarithmic Time
C. Linear Time
D. Quadratic Time
Any helpful information on this question would be appreciated.
When allocating an array of class objects, the constructor which takes no parameters is called, either the default or the user defined constructor. As usual if no, 'no parameters constructor' is defined but a constructor that does take parameters is defined, that will result in a compiler error
as for the worst case one, i think it's the quadratic, although i'm not too sure.
Instead of asking others for answers to your homework, perhaps you should actually do some research of your own. Besides, it's against board rules. ;)
Alright how about this.
How do you calculate worst case performance for a given function?