I can't seems to compile "foo = &myvar;" but I can compile "*foo = &myvar;"
Did I miss out any std files?
1 2 3 4 5 6 7 8 9 10 11 12 13
#include <iostream>
#include<stdio.h>
usingnamespace std;
int main()
{
int myvar = 25;
int foo = &myvar;
int bar = myvar;
int beth = *foo;
return(0);
}
int main()
{
int myvar = 25; // type of myvar is 'int'
// int foo = &myvar;
int* foo = &myvar; // type of foo is 'pointer to int'
int bar = myvar; // type of bar is 'int'
int beth = *foo; // type of beth is 'int'
}
The tutorial simply omits the types. You inferred them all to be int, which was incorrect. The tutorial intended for you to assume the types were those given by JLBorges.