Pointers - question

I have the next doubt in the documentation https://www.cplusplus.com/doc/tutorial/pointers/

We can see this example in how to access a var address.

1
2
3
  myvar = 25;
  foo = &myvar;
  bar = myvar;


so a real example should be like this:

1
2
3
 int my var = 25;
 int* foo = &myvar;
 int bar = myvar;


later we see this example:

1
2
  baz = foo;   // baz equal to foo (1776)
  baz = *foo;  // baz equal to value pointed to by foo (25) 


But in real code if i want to store foo i need to declare it in this way right?

1
2
   int* baz = foo;
   int baz = *foo;


Its that correct right?
Last edited on
Yes.
Topic archived. No new replies allowed.