I am having a problem with an assignment that I have to submit tomorrow which is to let a user construct an object. in the assignment it is asked from me to create a DVDshop class where the user can create a DVD object. Also, in this class I should have an array of actors but I don't know how to deal with array in objects(how to initialize them).

If I am letting the user set the values of the data member, do I still have to have a constructor for the class? because when I don't include a constructor I get an error!

Please help me out here, I am new to object-oriented C++,

When you instantiate a single instance of a c++ class the constructor is called, and that's where the class is initialized. The same thing happens when you create an array of c++ classes.

>>do I still have to have a constructor for the class?
Depends on the class, but in most cases you would create a constructor, and possibly more than one constructor, including the copy constructor. This is where you will initialize class data objects, such as initializing them to 0 or NULL.

Can I use the following set functin for the user entering the info the DVD object:

int DVD::setAddedActors()
	int n;
	cout<<"Enter the number of actors to be added: ";
	return n;
void DVD::setTitle()
	cout<<"Enter the title: ";
void DVD::setPrice()
	cout<<"Enter the price: ";
void DVD::setActors(int n)
	cout<<"Enter the actor(s): "<<endl;
	for(int i=0; i<n; i++)
		cout<<i+1<<") ";
void DVD::setDuration()
	cout<<"Enter the duration (min): ";
This article has been dead for over six months. Start a new discussion instead.