create vector in class

I have one project, and i need help if possible.
Here is piece of my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cout << "This is search \nenter (B) to go back " << endl << endl;
    getline(cin, Search);
    getline(cin, Search);
        for(int h=0; h < mySearch.size(); h++)
        {
        if(Search == mySearch[h].getName())
                  {
                  cout << mySearch[h].getName() << " - " 
                       << mySearch[0].getISBN() << " - ID: " << h << endl;
                       goto top;
                  }
        if(Search == backToMenu)
                  {
                  goto top;        
                  }



        }
    cout << "There is no that movie" << endl;
    goto top;


I want to this code make as function of one class. I dont know how..please help me if you cant..

Regards
What class are you trying to integrate it into? What you'll do is entirely dependent on that.
Here is my entire code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#include <iostream> 
#include <string> 
#include <vector>

using namespace std; 
//------------------------------------------------------------------------------
class Author
{
    private:
            string name;
            string surname;
            string country;
   public:
          Author(){}
          Author(string a, string b, string c);
          ~Author(){}  
          void setName(string n){  name = n ; }
           string getName(){ return  name; }
           void setSurname(string n){  surname = n ; }
           string getSurname(){ return  surname; }
           void setCountry(string n){  country = n ; }
           string getCountry(){ return  country; }      
};

Author::Author(string a, string b, string c){
    name  = a;
    surname = b;
    country = c;                  
}

//------------------------------------------------------------------------------

class Book{
    protected:
        string name;
        string ISBN; 
        string genre;
        Author* author;
    public:
          Book(){}
          Book(string a, string b, Author* c, string d);
          ~Book(){};
           void setName(string n){  name = n ; }
           string getName(){ return  name; }
           void setISBN(string n){   ISBN = n ; }
           string getISBN(){   return   ISBN; }
           void setGenre(string n) { genre = n; }
           string getGenre() { return genre; }
           void setAuthor(Author* n){    author = n; }
           Author* getAuthor(){   return   author; }
};

Book::Book(string a, string b, Author* c, string d){
    name  = a;
    ISBN = b;
    genre = d;
    author = c;                  
}


class Action: public Book{
      public:
      Action(){}
      Action(string e, string f, Author* g, string h);
      ~Action(){};
};

Action::Action(string e, string f, Author* g, string h){
    name  = e;
    ISBN = f;
    genre = h;
    author = g; 
                      
}


//------------------------------------------------------------------------------

int main()
{   
    int z,j,l=0,i,s;
    string backToMenu;
    backToMenu = "Back";
    string Search;
    
    Author* author = new Author("Mesa","Selimovic","Bosnia & Herzegovina");
    Author* author2 = new Author("Anton","Matos","Croatia");
   
   vector<Action> myAction; 
   vector<Book> myBooks;
   vector<Book> mySearch;
   vector<Book> myProfile;
   
   Book a("Batman","0123",author,"Action");
   Book b("Armagedon","0113",author,"Action");
   Book c("Gori vatra","0112",author,"Comedy");
   Book d("Badboys","0021",author2,"Action");
   Book e("Hellboy","0011",author2,"Thriller");
   Action f("Godfather","1234",author2,"Action");
   
   myBooks.push_back(a);
   myBooks.push_back(b);
   myBooks.push_back(c);
   myBooks.push_back(d);
   myBooks.push_back(e);
   myAction.push_back(f);
   
   for(s=0; s < myBooks.size(); s++)
   {
   mySearch.push_back(myBooks[s]);
   }
    for(int w=0; w < myAction.size(); w++)
   {
   mySearch.push_back(myAction[w]);
   }

   

//------------------------------------------------------------------------------     
   
              
//Choose menu, choose movie-----------------------------------------------------

   top:
   cout << "\n40 - MAIN MENU\n20 - PROFILE\n30 - SEARCH MOVIES\n ";
   while(l < myBooks.size())
   {
           cout << "\nType:  ";
           cin >> z;
           if(z == 40)
           {
                goto menu;
           }
           if(z == 20)
           {
                    goto profile;
           }
           if(z == 30)
           {
                   goto search;
           }
           if(z > 5 || z < 0)
           {
                cout << "There is no movie with this id!";
                continue;   
           }
   
//Stores selected movies in user profile box------------------------------------

   myProfile.push_back(mySearch[z]);
   cout << "You have choosen this movie: " 
        << mySearch[z].getAuthor()->getSurname() << " - " 
        << mySearch[z].getName() <<endl << endl;
   l++;
   continue;
   }
   
//Fills menu with movies, and prints them---------------------------------------
   menu:
        
   for(i=0; i < myBooks.size(); i++)
   {
   cout << myBooks[i].getName() << " - " << myBooks[i].getISBN() 
        << " - " << myBooks[i].getAuthor()->getSurname() 
        <<" id: " << i << endl;
   mySearch.push_back(myBooks[i]);
   }
   system("PAUSE");
   goto top;
  
//Profile box, shows which movie you have selected------------------------------ 

   profile:
           
   cout << "Your profile: " << endl;   
            
   for(j=0; j < myProfile.size(); j++)
   {
   cout << myProfile[j].getName() << " - " << myProfile[j].getISBN() 
   << " - " << myProfile[j].getAuthor()->getSurname() 
   << " - " << myProfile[j].getAuthor()->getCountry() 
   << " - " << myProfile[j].getGenre() << endl;
   }
   
   if(myProfile.empty()){
                         cout<<"There is no films borrowed. "<<endl<<endl;
                         }
   system ("PAUSE");
   goto top;

//Search box, using string shows wanted movie if exist-------------------------- 
 
    search:
           
    cout << "This is search \nenter (B) to go back " << endl << endl;
    getline(cin, Search);
    getline(cin, Search);
        for(int h=0; h < mySearch.size(); h++)
        {
        if(Search == mySearch[h].getName())
                  {
                  cout << mySearch[h].getName() << " - " 
                       << mySearch[h].getISBN() << " - ID: " << h << endl;
                       goto top;
                  }
        if(Search == backToMenu)
                  {
                  goto top;        
                  }



        }
    cout << "There is no that movie" << endl;
    goto top;

 
//Destructors-------------------------------------------------------------------  
   delete author;
   delete author2;

//------------------------------------------------------------------------------   
   system ("PAUSE");
   return 0;  
}
system(), don't use it.
Don't use goto's here, they are EVIL.

Fix those problems, then post it again.
Ok i will fix that..can you please tell me how to put "search" part of my code in one class. It is really urgent..tnx
Topic archived. No new replies allowed.