fixing the readme
This commit is contained in:
@@ -167,6 +167,26 @@ Add several test cases to test_vec.cpp to show that the function works as expect
|
|||||||
notation of your solution in terms of n the size of the vector, and e the number of occurences of the input
|
notation of your solution in terms of n the size of the vector, and e the number of occurences of the input
|
||||||
element in the vector?
|
element in the vector?
|
||||||
|
|
||||||
|
*Note*: when you are in a non-member function, and you want to use the iterator, which is a member type of the Vec<T> class, you have to use the typename keyword before the Vec<T>:: scope. For example, if you want to define an iterator named *itr*, you can do it like this:
|
||||||
|
|
||||||
|
```console
|
||||||
|
typename Vec<T>::iterator itr
|
||||||
|
```
|
||||||
|
|
||||||
|
without this typename keyword, if you define the iterator *itr* like this:
|
||||||
|
|
||||||
|
```console
|
||||||
|
Vec<T>::iterator itr
|
||||||
|
```
|
||||||
|
|
||||||
|
you will get a compiler error saying:
|
||||||
|
|
||||||
|
```console
|
||||||
|
error: need ‘typename’ before ‘Vec<T>::iterator’ because ‘Vec<T>’ is a dependent scope
|
||||||
|
```
|
||||||
|
|
||||||
|
And the reason that this keyword typename is needed, is because without it, the compiler would think that Vec<T>::iterator is a member variable of the Vec<T> class, but this *typename* explicitly tells the compiler that Vec<T>::iterator is a type, rather than a member variable.
|
||||||
|
|
||||||
**To complete this checkpoint**, show a TA your debugged solution for remove_matching_elements and
|
**To complete this checkpoint**, show a TA your debugged solution for remove_matching_elements and
|
||||||
be prepared to discuss the order notation of the function.
|
be prepared to discuss the order notation of the function.
|
||||||
|
|
||||||
@@ -174,8 +194,8 @@ be prepared to discuss the order notation of the function.
|
|||||||
*estimate: TBD*
|
*estimate: TBD*
|
||||||
|
|
||||||
Add a print member function to Vec to aid in debugging. (Note, neither remove_matching_elements nor
|
Add a print member function to Vec to aid in debugging. (Note, neither remove_matching_elements nor
|
||||||
print are not part of the STL standard for vector). You should print the current information stored in the
|
print are part of the STL standard for vector). You should print the current information stored in the
|
||||||
variables m_alloc, m_size, and m_data. Use the print function to confirm your remove_matching_elements
|
variables capacity, m_size, and m_data. Use the print function to confirm your remove_matching_elements
|
||||||
function is debugged. Also, write a test case that calls push_back many, many times (hint, use a for loop!)
|
function is debugged. Also, write a test case that calls push_back many, many times (hint, use a for loop!)
|
||||||
and observe how infrequently re-allocation of the m_data array is necessary.
|
and observe how infrequently re-allocation of the m_data array is necessary.
|
||||||
To verify your code does not contain memory errors or memory leaks, use Valgrind and/or Dr. Memory on
|
To verify your code does not contain memory errors or memory leaks, use Valgrind and/or Dr. Memory on
|
||||||
|
|||||||
@@ -124,8 +124,9 @@ v[0] = 13.1; v[2] = 3.14;
|
|||||||
Vec<double> u(v);
|
Vec<double> u(v);
|
||||||
u[2] = 6.5;
|
u[2] = 6.5;
|
||||||
u[3] = -4.8;
|
u[3] = -4.8;
|
||||||
for (unsigned int i=0; i<4; ++i)
|
for (unsigned int i=0; i<4; ++i){
|
||||||
cout << u[i] << " " << v[i] << endl;
|
std::cout << u[i] << " " << v[i] << std::endl;
|
||||||
|
}
|
||||||
```
|
```
|
||||||
Explain what happens by drawing a picture
|
Explain what happens by drawing a picture
|
||||||
of the memory of both u and v.
|
of the memory of both u and v.
|
||||||
|
|||||||
Reference in New Issue
Block a user