algorithm - general programming issue on classes -


let's want create movie database software.

i need class actor have attribute name, surname, dob, awards, , should have array of "movie" object.

i need class movie, have attribute title, duration, year, should have array of "actor" object. represent cast of movie.

actor object need list of movie done actor, movie object need list of actors played in it. gets quite messy cause it's class containing 1 , viceversa, compiler stuck.

which right way represent situation?  

in languages concept same. you've observed, can't have "lists of movie objects" embedded in actors , vice versa, instead keep list of each , "reference" other objects in way. might using unique reference value (e.g. incrementing number) can used search other list or associative container (e.g. use key/value "std::map" in c++ rather linked list), or keeping reference or (weak) pointer directly logically linked objects....


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -