C++ Programming Tutorial 52 - Passing Vectors to Functions

preview_player
Показать описание


~~~~~~~~~~~~~~~ CONNECT ~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~ SUPPORT ME ~~~~~~~~~~~~~~

🅑 Bitcoin - 3HnF1SWTzo1dCU7RwFLhgk7SYiVfV37Pbq
🅔 Eth - 0x350139af84b60d075a3a0379716040b63f6D3853
Рекомендации по теме
Комментарии
Автор

Thank you so much, I was overthinking how to do this so much. Can't believe how simple it really is

trgby
Автор

Thank you for making tutorial like this, I can't believe how these videos only have a few thousand views. Your cpp tutorials are making me pass my class easily.

chriscruz
Автор

During this lockdown in France, only these videos are helping me keep my sanity. Thanks Caleb.

abhishekpariyar
Автор

thanks my man this is very informative!!! was just looking about how to make a vector template & passing it around to functions, I'll just keep looking! great channel, just subbed

danial_amini
Автор

hello, could you explain more about passing by value vs passing by reference? THANK YOU VERY MUCH

zsoulz
Автор

Big thank to u. Ur explanation is easy understood and simplifying

mohammedaladaqf
Автор

good practice:
dont put data.size inside loop condition because each time it will goo and calculate the size and that not good optimization, instead crest variable int s= data.size(), and put s inside the loop condition

abdelrhmanahmed
Автор

Thank you for that. I was taught nothing about vectors, and suddenly I had to use them in an assignment at my university. I might just prevail because of watching two or three of your videos on vectors!

jamshaidmushtaq
Автор

If we want to return a vector how should we do??

sunrise_vlogs_daily
Автор

Easy enough, but it should be important to note that the the new line escape character in modern programs should be replaced by endl. Also since vectors are not primitive data types and you are not changing the vector within the function wouldnt you suggest passing by const reference opposed to passing by value?

AdamCJost
Автор

Thanks for these wonderful videos; I think they're a great &!

PunmasterSTP
Автор

Awesome stuff! Now how to return vectors from functions?

brocklesnarufcchamp
Автор

I had to declare my variable before like this:
int sample;
std::vector<int> sample = {1, 2, 3};
print_vector(sample);
Or I got an error. I dunno why.

damnnits
Автор

Now if the print vector actually returns the modified vector back to the main function. Does the print vector copied vector free up the memory?

dbaby
Автор

Regarding using the i's in the for loop, do we always use i? Can we use any character? I'm just confused as to why it's i when there's no i anywhere else in the program, I think I might have to rewatch your for loop video again!

kdtallllll
Автор

People outside the door, eh? Sometimes people are better left outside. Burn. xD

guitarhax
Автор

I keep getting an error with the for(int i = 0; < data.size(); i++) in the <.
The error is rror: expected primary-expression before '<' token
6 | for(int i = 0; < data.size(); i++). Any help?

DanmanJR
Автор

hello i am from iraq, what is library that contains "vectors", ,

alnajafyprogrammer
Автор

#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>

using std::cout;
using std::cin;


void print(std::vector<int> one)
{

for (i = 0; i < one.size();i++)
{
cout << one[i] << "\t";

}
}

int main()
{
std::vector<int> two = { 1, 2, 3 };
print(one);



}

hey Caleb can you please tell me what's wrong with my code?

ammgnero
Автор

Why on Earth would you not explain how to return a value

anthonychadwick