Error cannot convert Movies* to Movie* in assignment

In Movies.cpp at the bottom of the Movies* createMovies() function

[code]
////////////////////////////////////////////////////////////////////
//Movie.h

#ifndef MOVIE_STRUCT
#define MOVIE_STRUCT

#include <string>

using namespace std;

struct Movie
{
string title;
string director;
long year;
int time;
int num;
};

Movie* createMovie(string title, string director, long year, int time, int num);
void displayMovie(Movie* m);
void destroyMovie(Movie* m);

#endif
///////////////////////////////////////////////////////////////////////////
//movie.cpp

#include <string>
#include <iostream>
#include "movie.h"

using namespace std;

Movie* createMovie(string title, string director, long year, int time,int num)
{
Movie* m = new Movie;
m -> title = title;
m -> director = director;
m -> year = year;
m -> time = time;
m -> num = num;

return m;
}

void displayMovie(Movie* m)
{
cout << m -> title << endl;
cout << m -> director << endl;
cout << m -> year << endl;
cout << m -> time << endl;
}

void destroyMovie(Movie* m)
{
delete m;
}

#ifndef MOVIES_STRUCT
#define MOVIES_STRUCT
/////////////////////////////////////////////////////////////////////////
//movies.h

#include <string>
#include "movie.h"

using namespace std;

struct Movies
{
int num;
Movie** m_array;
};

Movies* createMovies(int _num);

void displayMovies(Movies* m);

void destroyMovies(Movies* m);

#endif
/////////////////////////////////////////////////////////////////////////////
//movies.cpp

#include "movies.h"
#include <iostream>
#include <string>
#include <fstream>


using namespace std;

Movies* createMovies(int _num)
{
string title, director;
long year;
int time = 0;
int count = 0;
int num;
fstream outF;
outF.open("movies.txt", ios::out);

num = _num;

Movies* m = new Movies;
m -> num = _num;
m -> m_array = new Movie*[num];
cout << "Movie Title : ";
cin >> title;
outF << title << endl;
cout << "Director : ";
cin >> director;
outF << director << endl;
cout << "Year Released : ";
cin >> year;
outF << year << endl;
cout << "Movie length in minutes : ";
cin >> time;
outF << time << endl;

outF.close();

while (count < num)
{
m -> m_array[m -> num] = m;
}
count++;

return m;
}

void displayMovies(Movies* m)
{
int num = m -> num;
Movie** m_array = m -> m_array;

for (int i = 0; i < num; num++)
{
displayMovie(m_array[i]);
}
}

void destroyMovies(Movies* m)
{
int num = m -> num;
Movie** m_array = m -> m_array;

for (int i = 0; i < num; i++)
{
destroyMovie(m_array[i]);
}
delete m;
}


[\code]
Last edited on
Never mind, I see the problem. I never put, "Movie* m = createMovie()"
Might be a good idea to preview your code to see if it actually appears in code form :p
You know, this is the exact problem constructors were created to solve.
Topic archived. No new replies allowed.