Goal:
Use a struct that has 4 fields, input to those fields, and pass to function to display.
Problem:
(38) : error C2365: 'displaySData' : redefinition; previous definition was 'data variable'
Code:
#include <iostream>
#include <string>
using namespace std;
//prototypes
void displaySData(MovieData, MovieData);
struct MovieData
{
string Title;
string Director;
string YearReleased;
string RunTime;
};
int main()
{
MovieData data1;
MovieData data2;
// Get input for struct var 1
cout<<"Enter the title of the movie:\n";
cin>>data1.Title;
cout<<"Enter the director of the movie:\n";
cin>>data1.Director;
// Get input for struct var 2
cout<<"Enter the release date (year) of the movie:\n";
cin>>data2.YearReleased;
cout<<"Enter the run time (minutes) of the movie:\n";
cin>>data2.RunTime;
// Function for display
displaySData(data1, data2);
system("Pause");
return 0;
}
void displaySData(MovieData d1, MovieData d2)
{
cout<<d1.Title<<"\n";
cout<<d1.Director<<"\n";
cout<<d2.YearReleased<<"\n";
cout<<d2.RunTime<<"\n";
}
C++ Masters.. Please help me..