Why is it giving me error? (Pointer array)

I am confused as to why it gives error when I try to use a pointer array like this:

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
40
41
42
43
44
//Don't mind the whole class nonsense
#include <iostream>
#include <string>
#include "Fish.h"
using namespace std;

void inputData(const int *const, Fishing*);

int main()
{
	Fishing *fishData;
	int 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;
	}

	fishData=new Fishing[fishnum];

        inputData(pnum,fishData);
}

//Gives error if I don't include the [] after "data" pointer array
void inputData(const int *const num, Fishing *data)
{
	string strVar;
	double doubVar;

	for(int i=0;i<(*num);i++)
	{
		cout<<"Enter data for fish #"<<(i+1)<<": "<<endl;
		cout<<"Type: ";
		cin>>strVar;
                //Giving me error here, fixes when I add [] to the top of function
		data[i]->setFishType(strVar);

	}
}


Yet the same thing works just fine here:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <cstdlib>
using namespace std;

void displayAll(const int *const, int);

int main()
{
	const int NUM=5;
	int num[NUM]={1,2,3,4,5};
	int *numpt=num;

	displayAll(num,NUM);

}

//No [] on the pointer array yet it runs just fine
void displayAll(const int *const arr, int NUM)
{
	for(int i=0;i<NUM;i++)
	{
		cout<<arr[i]<<endl;
	}
}
data[i] equivalent to *(data+i): pointer already dereferenced, so you should use operator "." instead of "->"
Nice thank you
Topic archived. No new replies allowed.