-
How to create a container class?
Dear friends,
I am new to Visual C++ and I am trying to create a Menu class that has a
container class that can hold a MAX of 3 films. Can anyone help me with
an
example on how to create this container class?
I have this so far......
class MyMenu class definition
{
private:
char ch;
public:
MyMenu();
~MyMenu();
display_MyMenu();
};
#endif
In my display_MyMenu() member function I have to create a Menu.
I have done this so far........
MyMenu::MyMenu() file://constructor
{}
MyMenu::~MyMenu() file://destructor
{}
MyMenu::display_MyMenu()
{
char ch;
cout << "\n\t ****** MAIN MENU ****** \n";
cout << "----------------------------\n";
cout << "(e)nter a new film\n";
cout << "(d)elete a film\n";
cout << "(f)ind a film\n";
cout << "(x)Exit the program\n";
cout << "----------------------------\n";
switch(ch)
{
case 'e':
Do something.........
break;
case 'd':
cout << "delete a film?\n";
break;
case 'f':
cout << "find a film?\n";
case 'x':
break;
}
}
However, I do not understand how to create a container class...I am new to
learning VC++ and I cannot seem to find anything that tells me how to create
a container class. Any ideas would be greatly appreciated.
Thanks in advance,
Brad Isaacs
-
Re: How to create a container class?
A container class is just a class that can hold a set of objects. It seems
that you need to write a class Menu that can hold 3 objects of type Film
and give user access to those items via accessor functions like display_MyMenu.
Therefore, if I were trying to implement this design, I would start by implementing
a class Film and then implementing a class Menu that can "contain" Film objects.
Hope this helps,
-Patrick
"Beginner-Brad" <bradhouse@sprint.ca> wrote:
>
>Dear friends,
>
>I am new to Visual C++ and I am trying to create a Menu class that has a
>container class that can hold a MAX of 3 films. Can anyone help me with
>an
>example on how to create this container class?
>
>I have this so far......
>
>class MyMenu class definition
>{
>private:
>
> char ch;
>public:
> MyMenu();
> ~MyMenu();
> display_MyMenu();
>};
>#endif
>
>In my display_MyMenu() member function I have to create a Menu.
>I have done this so far........
>MyMenu::MyMenu() file://constructor
>{}
>
>MyMenu::~MyMenu() file://destructor
>{}
>
>
>MyMenu::display_MyMenu()
>{
>
> char ch;
> cout << "\n\t ****** MAIN MENU ****** \n";
> cout << "----------------------------\n";
> cout << "(e)nter a new film\n";
> cout << "(d)elete a film\n";
> cout << "(f)ind a film\n";
> cout << "(x)Exit the program\n";
> cout << "----------------------------\n";
>
>
>
> switch(ch)
> {
> case 'e':
> Do something.........
> break;
> case 'd':
>
> cout << "delete a film?\n";
> break;
> case 'f':
>
> cout << "find a film?\n";
> case 'x':
> break;
> }
>
>
>}
>
>
>
>However, I do not understand how to create a container class...I am new
to
>learning VC++ and I cannot seem to find anything that tells me how to create
>a container class. Any ideas would be greatly appreciated.
>
>Thanks in advance,
>
>Brad Isaacs
>
>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|