Passing Pointers to Functions -- C++ Pointers Tutorial [7]

preview_player
Показать описание
Let's learn how you can use pointers as function parameters. We'll see how you can pass pointers by value and by reference. In this C++ programming tutorial for beginners, you'll learn through coding examples done using Visual Studio Community.

// Learn More

// Consider supporting this channel in multiple ways
Bitcoin: 177wfkQwzXiC8o2whQMVpSyuWUs95krKYB
Dogecoin: DRK2HDp3ZkkbFpvGZnVgMVosnBhPv8r3uP
Рекомендации по теме
Комментарии
Автор

How did you call the swap function when it was named foo ?

TonyB-cyqd
Автор

Thank you... Adding this to my "watch again" list.

ianneill
Автор

This guy is underrated i love your content!

emreibrahim
Автор

@13:38, line 23; Sir you are using std::swap() instead of the foo() that you defined above.
Amazing video nonetheless, thanks a billion- I feel so much better about C++!

jawwad
Автор

I needed a review on this thank you so much!

WCH
Автор

I have been struggling with the content that you mentioned in this video before. Thanks a lot.

leowatote
Автор

thank you so much, this cleared up so many things

cornondanob
Автор

Great explanation. Congrats!!! To be clear when we create a pointer parameter "foo(int * a)" the compiler will create a new pointer variable that points to the the same place of what we pass is pointing too right?

Byynx
Автор

#include <bits/stdc++.h>
using namespace std;
void random(int*&c, int*&d)
{
int p=7, q=8;
c=&p;
d=&q;
}
int main() {
int a=2, b=3;
int *c=&a, *d=&b;

random(c, d);
cout<<*c<<" "<<*d<<endl;
cout<<*c<<" "<<*d<<endl;

return 0;
}



//Sir, in the 14th and 15th line I wrote the same line to print, , but got different outputs, why?

Cuteartandcraft-nx