Originally Posted by
jimblumberg
You may want to consider using std::vector instead of arrays.
Because it's not the first time today I see someone's mentioned these vectors I decided to give it a shot... and I'm confused a litte.
So I have my class movie, I declare vector:
Code:
vector <movie> base;
How do I access my methods, in this case setMovie()?
Code:
void movie::setMovie(){
cout<<" What is the title? ";
getline(cin,title);
cout<<" Who is the director? ";
getline(cin,director);
cout<<" Who wrote scenario? ";
getline(cin,scenario);
cout<<" When the movie has been released? ";
cin>>year;
cin.get(); //"swalows" \n that has been left in buffor
cout<<" What is the genre? ";
getline(cin,genre);
cout<<" How long is the film (in minutes)? ";
cin>>lenght;
cin.get(); //"swalows" \n that has been left in buffor
cout<<" What's the country of the movie? ";
getline(cin,country);
cout<<" Type names of 3 actors that play main roles: ";
getline(cin,leading_role1,'\n');
cout<<" ";
getline(cin,leading_role2,'\n');
cout<<" ";
getline(cin,leading_role3,'\n');
cout<<" What is the price per day?: ";
cin>>price;
cin.get(); //"swalows" \n that has been left in buffor
}
Code:
base.push_back(???)
//this is where I want to
//add in the end of a vector
//an object by calling method setMovie()