Enable contrast version

Tutor profile: Jake H.

Inactive
Jake H.
Tutor for 3 years, Software Engineer
Tutor Satisfaction Guarantee

Questions

Subject: Portuguese

TutorMe
Question:

How would you order 5 pieces of cheese bread?

Inactive
Jake H.
Answer:

Eu gostaria cinco pedaços de pão de queijo, por favor.

Subject: Javascript Programming

TutorMe
Question:

How can you copy an array $$arr1$$ into another array $$arr2$$ and change items in $$arr2$$ without changing items in $$arr1$$, and without using a loop to copy items over?

Inactive
Jake H.
Answer:

Use the spread syntax $( const arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const arr2 = [...arr1]; arr2[0] = 20; console.log(arr2[0], arr1[0]); $)

Subject: C++ Programming

TutorMe
Question:

When working in C++, if you don't know how many items you are going to need to store in a data structure, is it better to use std::array or std::vector? How would you initialize and add items to both?

Inactive
Jake H.
Answer:

std::vector is much better to use when you don't know how many items you are going to need to store. It allows for dynamic memory allocation, and provides a straightforward and semantic api to use with it. Add to an array: $( #include <iostream> #include <array> #include <algorithm> int main() { //initialize the arrays std::array<int, 5> myArr = {1, 2, 3, 4, 5}; std::array<int, 6> myArr2; //copy the old array into the new array std::copy(myArr.begin(), myArr.end(), myArr2.begin()); //add the new item to the new array myArr2[5] = 6; //print for (int i = 0; i < myArr2.size(); i++) { std::cout << myArr2.at(i) << std::endl; } } $) Add to a vector $( #include <iostream> #include <vector> int main() { std::vector<int> myVec; myVec.push_back(1); myVec.push_back(2); myVec.push_back(3); for (int i = 0; i < myVec.size(); i++) { std::cout << myVec.at(i) << std::endl; } } )$

Contact tutor

Send a message explaining your
needs and Jake will reply soon.
Contact Jake

Request lesson

Ready now? Request a lesson.
Start Lesson

FAQs

What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Lesson" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.
BEST IN CLASS SINCE 2015
TutorMe homepage
Made in California by Zovio
© 2020 TutorMe, LLC
High Contrast Mode
On
Off