When passing in the mr object into MovieDB, the whole thing becomes empty. Please kindly assist to see what is wrong?
I am aware that, instead of passing in a MovieRecord mr object to MovieDB, I can split up the object's 6 private variables and pass them in individually, but it seems kind of non-OO to me.
Could it be the fact that the variables in any MovieRecord is only populated via getURL() function?
If yes, please kindly suggest any ways that I can do it.
kbw is correct and that will avoid your problem, though I'm going to guess that the
root cause of your problem is an incorrectly coded copy constructor for MovieRecord
(since you declared one, you must implement it, and I'm guessing yours is empty?)
A better implementation of the above (none is technically needed since the default copy constructor provided
by the compiler does the same thing):
1 2 3 4 5 6 7 8 9
// Use of initializer lists instead of assignment is recommended.
// Members should be initialized in the order of declaration (the
// compiler will reorder them anyway. A reasonable compiler
// will give a warning if you don't put them in the right order)
MovieRecord::MovieRecord( const MovieRecord& r ) :
title( r.title ), director(), cast(), dateOfRelease(),
synopsis(), RunningTime( r.RunningTime )
{
}