Structure of Arrays with functions

I created this program to store data about a Movie. The function names that are inside the int main appear underlined with red, but I'm not sure what's wrong with it. The error is "more than one instance of overloaded function "getMovieData" matches the argument list:". Same thing with the rest of the function names in int main.

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <iostream>
using namespace std;

const int SIZE=50

struct MovieData{
	char title[SIZE];
	char director[SIZE];
	int yearRls[SIZE];
	int runTime[SIZE];
	int cost[SIZE];
	int revenue[SIZE];
};

void getMovieData(MovieData movieArray[], int size);
void getCostRev(MovieData movieArray[], int size);
void printMovieData(MovieData movieArray[], int size);
int ProfitOrLoss(MovieData movieArray[], int size);

int main(){

	const int size1=50;
	const int size2=50;

	MovieData movie1, movie2;

	getMovieData(movie1, size1);
	printMovieData(movie1,size1);

	getMovieData(movie2, size2);
	printMovieData(movie2, size2);
	
	getCostRev(movie1, size1);
	ProfitOrLoss(movie1, size1);

	getCostRev(movie2, size2);
	ProfitOrLoss(movie2, size2);

	return 0;
}

void getMovieData(MovieData mov[], int size){
	cin.ignore();
	cout<<endl;
	cout<<"Enter the title of the Movie: "; //enters the name of a movie
	cin.getline(mov[size].title, '\n');

	cout<<"Enter the name of the director: ";
	cin.getline(mov[size].director,'\n');  //enters the name of the director

	cout<<"Enter the release date of the movie: ";
	cin>>mov[size].yearRls;       //enters the year of release

	cout<<"Enter the running time of the movie in minutes: ";
	cin>>mov[size].runTime; //enters the how long the movie lasts
}

void getCostRev(MovieData mov[], int size){
	cout<<"What were the costs of"<<endl;  //enters the cost of the movie
	cout<<"the movie "<<mov[size].title<<" ?: ";
	cin>>mov[size].cost;
	cout<<"What were its revenues?: "; //enters the revenues by the movie
	cin>>mov[size].revenue;
}

int ProfitOrLoss(MovieData mov[], int size){
	int profit=0, loss=0;  //initializes profit and loss

	if(mov[size].cost<mov[size].revenue){    //if the movie profits, it 
                                                  //shows how much is the 
                                                  //profit

		profit+=mov[size].revenue - mov[size].cost;  
		cout<<endl;
		cout<<"First years profit: "<<profit<<endl;
		cout<<endl;

		return profit;	
	}
	if(mov[size].cost>mov[size].revenue){
		loss+=mov[size].revenue - mov[size].cost;  //if the movie was a 
                                                           //loss, it shows how
                                                           //much is the loss
		cout<<endl;
		cout<<"First years loss: "<<loss<<endl;
		cout<<endl;	
	}
	return loss;
}

void printMovieData(MovieData mov[], int size){  
	cout<<endl<<endl;
	cout<<"-------------------------------------------"<<endl;
	cout<<"\t\t Movie Data       "<<endl;
	cout<<"-------------------------------------------"<<endl;
	cout<<"Movie Title                | "<<mov[size].title<< endl;;
	cout<<"                           | "<<endl;
	cout<<"Director                   | "<<mov[size].director<<endl;
	cout<<"                           | "<<endl;
	cout<<"Release Year               | "<<mov[size].yearRls<<endl;
	cout<<"                           | "<<endl;
	cout<<"Movie Runtime in minutes   | "<<mov[size].runTime<<endl;
	cout<<"-------------------------------------------"<<endl;
	cout<<endl;
}
Last edited on
the function getMovieData takes, as an argument, an array. movie1 is not an array. You repeat this problem throughout.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int main(){

	const int size1=50;
	const int size2=50;

	MovieData movie1[size1], movie2[size2];

	getMovieData(movie1, size1);
	printMovieData(movie1,size1);

	getMovieData(movie2, size2);
	printMovieData(movie2, size2);
	
	getCostRev(movie1, size1);
	ProfitOrLoss(movie1, size1);

	getCostRev(movie2, size2);
	ProfitOrLoss(movie2, size2);

	return 0;
}


Just changed it, but it still gives me the same problem.
closed account (o3hC5Di1)
Hi there,

I think the problem lies here, as an example:

Declaration before main:

void getMovieData(MovieData movieArray[], int size);

Declarator after main:

void getMovieData(MovieData mov[], int size)

You are using different names for the arrays. Either don't name it in your first declaration, or give both the same name.

All the best,
NwN
Topic archived. No new replies allowed.