#include int main() { // pointers = variable that stores a memory address of another variable // sometimes it's easier to work with an address // & address-of operator // * dereference operator std::string name = "Bro"; int age = 21; std::string freePizzas[5] = {"pizza1", "pizza2", "pizza3", "pizza4", "pizza5"};
if its not clear to everyone, arrays are just pointers, which point to the first element in the list, for example: arr[i] is the same as *(arr + i), its also one of the reasons you can write i[arr] in C++ and it will give the same output as arr[i], there is also other things that are possible with arrays/pointers: #include int main(int argc, char *argv[]) { int size = 3; int array[size] = {10, 5, 3, 1, -2, -4, -7}; std::cout
@@game-op8up yeah, thats why you use int pointers not string pointers. infact myarray[index] is defined in C/C++ to be equivalent to *(myarray + index), thats why while accessing first element by using myarray[0], like in the video, is equivalent to *(myarray + 0) = *(myarray) = *myarray.
Why it didn't give the error in string *pname =&name; int *pAge =&age; But gives the error in string *freepizzas =&freepizzas Why can't we use "&" in this but can use in those above
Look let's imagine that the int and string are taking 1 space in memory so when I want to get them I call the address of this space but in array you have 5 spaces each one is separated just they are in like a container named array and this array addressed by the first value so when you want to point a pointer on array you cannot make a pointer point to all those spaces hope you got it
why does the output to your freepizzas array and the pointer to said array differs when arrays are already pointers? i tried it myself and for me it outputs the same thing
@@jerryjerryjerry1 How do you know that? Bro Code dedicates his time to create quality content for his viewers. His video tutorials are great yet he doesn't show up himself. His videos has helped me a lot. I think Bro Code is a good person.
#include
int main() {
// pointers = variable that stores a memory address of another variable
// sometimes it's easier to work with an address
// & address-of operator
// * dereference operator
std::string name = "Bro";
int age = 21;
std::string freePizzas[5] = {"pizza1", "pizza2", "pizza3", "pizza4", "pizza5"};
std::string *pName = &name;
int *pAge = &age;
std::string *pFreePizzas = freePizzas;
std::cout
if its not clear to everyone, arrays are just pointers, which point to the first element in the list, for example: arr[i] is the same as *(arr + i), its also one of the reasons you can write i[arr] in C++ and it will give the same output as arr[i], there is also other things that are possible with arrays/pointers:
#include
int main(int argc, char *argv[])
{
int size = 3;
int array[size] = {10, 5, 3, 1, -2, -4, -7};
std::cout
brain goes boom boom
brain goes burrrrrrr thank you
if arrays is already an address why would i ever use pointer for that?
int diddy = 1000;
int *pDiddy = &diddy;
address of operator: pDiddy Party
int pointer = 100;
int *pPointer = &pointer
double long babyOil;
If I want to locate the pizza3 in the array ,how should I use my pointer?
Instead of this:
std::cout
@@game-op8up yeah, thats why you use int pointers not string pointers. infact myarray[index] is defined in C/C++ to be equivalent to *(myarray + index), thats why while accessing first element by using myarray[0], like in the video, is equivalent to *(myarray + 0) = *(myarray) = *myarray.
std::string freePizzas[] = {"pizza1", "pizza2", "pizza3", "pizza4", "pizza5"};
std::string* pFreePizzas = freePizzas;
std::cout
bro you are so amazing you solved my biggest problem
of pointers love U😘😘😘😘😘😘😘😘
Bro has the best videos ngel. W bro❤❤👍
Why it didn't give the error in
string *pname =&name;
int *pAge =&age;
But gives the error in
string *freepizzas =&freepizzas
Why can't we use "&" in this but can use in those above
Look let's imagine that the int and string are taking 1 space in memory so when I want to get them I call the address of this space but in array you have 5 spaces each one is separated just they are in like a container named array and this array addressed by the first value so when you want to point a pointer on array you cannot make a pointer point to all those spaces
hope you got it
Not really but it was a little bit helpful. Thank you brother 🙋🏻♂️@@ahmed7aleem943
assignment: #include
int main()
{
double gpa[] = {2.5, 3.3, 4.3, 5.0, 4.05};
double *pGPA = gpa;
for (int i = 0; i < 5; i ++)
{
std::cout
Looks like an f to me😭
int main{
std:: string = Bruh;
std:: string = *pBruh = &Bruh;
std::cout
Thank you!❤
why does the output to your freepizzas array and the pointer to said array differs when arrays are already pointers?
i tried it myself and for me it outputs the same thing
float pointy = 0.34;
float *pPointy = &pointy;
cout
Thank you! It looks like I just kept forgetting the & which is why my code never worked for my homework
why don't you use namespace std : (
I'm watching the 6 hours c++ tutorial he made, and there he says that he doesn't like doing that
I think it was considered bad practice cuz other libraries might have functions with the same name
It's because it increases the chance for a namespace collision.
He already use :: std if u use (::std) you don’t need using namespace std:
@@HiboMohits an ease of use thing not a need thing. if you put use namespace std or define std functions u can just say string instead of std::string
gbu
#include
int main() {
double temp = 44.2;
double *pTemp = &temp;
std::cout
#include
int main()
{
char grades[5] = {'A', 'B', 'C', 'D', 'F'};
char *pGrades = grades;
std::cout
free pizza is crazy
Yeah, where is this memory address with all this free pizza?
@@NotLiamHpizza
Thanks.
yesssss. keep the updates flowing :3
now i want a free pizza
Bro, why don't you show yourself on your video tutorials ? I think it would be more interactive for your pupils or fans to engage learning.
because he is evil
hes dream
@@jerryjerryjerry1 How do you know that? Bro Code dedicates his time to create quality content for his viewers. His video tutorials are great yet he doesn't show up himself. His videos has helped me a lot. I think Bro Code is a good person.
i think you should suck it dude
@@HunaBopa
It’s better not to show his face
int pizza =15;
int *pPizza=&pizza;
cout
int main() {
std::string name = "Marcus";
std::string *pName = &name;
std::cout
int main(){
string favouriteGames[5] = {"Overwatch 1", "Terraria", "Rocket League", "Minecraft", "Overwatch 2"};
string *pFavouriteGames = favouriteGames;
cout
why arrays are already addresses?
@@zinebell3225 because the array's name itself
represents the address of its first element.
@@SauravKumar-lq6hr how to access the exact game in the array list? for example Overwatch 2?