When to use pointers in this kind of situation?

Our teacher said that from now on we should only be using pointers, but how far does that actually go? Do you use a pointer for every single variable you are going to use? Like in the following example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <string>
#include "Fish.h"
using namespace std;

int menu();
void inputData(int *const, Fishing*);
void displayData();
void exit();

int main()
{
	Fishing *fishData;
	int fishnum,
             //Pointer initialized to fishnum
	    *pnum=&fishnum,
	    option;

	cout<<"Enter the number of fish caught: ";
	cin>>*pnum;
	while(*pnum<0)
	{
		cout<<"ERROR. Please enter a positive value: ";
		cin>>*pnum;
	}

        //Here, should I send the pointer instead?
	fishData=new Fishing[fishnum];

        //Here, should I equate the same pointer to option then replace "option" with the pointer?
        //Ex: pnum=&option;
        //Ex: *pnum=menu();
	option=menu();

	switch(option)
	{
		//etc etc
	}
}


Think what I am asking is basic programming practice. Does he literally mean that we should use a pointer for every single variable including constants, or is it suitable to only use them when getting user-input data?
Last edited on
You should only use pointers when you need to. Normal variables are perfectly fine until then.
Topic archived. No new replies allowed.