Using Pointers or variables

Hey,
I am a beginner user of c++.
and I have a question concerning pointers.
Is there any deference for using regular variables, while programming, or pointers to avoid messing up with the variables?
Could you give a snippet of code? I am not sure that I can understand what you are asking without seeing a code example. Deference is not the same as dereference, so I am confused by your question.
for example :
ex1:
1
2
3
4
int a;
cout<<"Insert value: ";
     cin>>a;
cout<<"the input is : "<<a<<endl;

ex2:
1
2
3
4
5
int a, *pa;
pa=&a;
cout<<"Insert value :";
    cin>>*pa;
cout<<"the input is : "<<a<<endl

I would like to know if on a "Much longer and complicated program" it is better to use pointers to get values or just use regular variables
Use values (regular variables).
Use pointers only if something can't be done without using pointers.
Between those two examples you just posted, ex1 is much better. I actually prefer variables instead of pointers in almost every situation. Variable references are always guaranteed to be allocated, whereas pointer references lack that guarantee.
Topic archived. No new replies allowed.