pointer

can pointer point to 2 variables at one time?
No, a pointer can only point to one location at a time.
Put this 2 variables in a struct.
Or into an array, if the variables have same type.


A pointer is a variable that holds one numeric value. The value is interpreted as a memory address.
like @coder777 said make a simple struct like so :

1
2
3
4
5
6
7
8
9
10
11
12
13
struct Structure
{
 int var1;
 int var2;
} *pointer;

 int main()
{
  pointer = new Structure(1,2);
  cout << pointer << endl;
  cout <<  pointer->var1 << endl;
 cout << pointer->var2 << endl;
 return 0;

}
Topic archived. No new replies allowed.