#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
@@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 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
@@bigheaddanny3377 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.