a friend have started learning c++ and send me this code, i bet that the code wont work, here is the code:
class Pelicula {
private:
std::string titulo;
int duracion;
int lanzamiento;
public:
// Constructor
Pelicula(const std::string& titulo, int duracion, int lanzamiento) {
this->titulo = titulo;
this->duracion = duracion;
this->lanzamiento = lanzamiento;
std::cout << "Se ha creado la pelicula: " << titulo << std::endl;
}
// Destructor
~Pelicula() {
std::cout << "Se está borrando la pelicula: " << titulo << std::endl;
}
// Sobrecarga del operador <<
friend std::ostream& operator<<(std::ostream& os, const Pelicula& pelicula) {
os << pelicula.titulo << " lanzada en " << pelicula.lanzamiento
<< " con una duración de " << pelicula.duracion << " minutos.";
return os;
}
};
help me make him see reason
New contributor
Angel gabriel Landin Gutierrez is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.