Changing the using to class inheritance

Can anyone teach and guide me how to change the "using" to a class inheritance format

1
2
3
4
5
6
7
8
  class Movie
{
    public:
        string name, day, time1, time2, time3;
};

using MOVIE = Movie[MAXMOVIES];
I'm not sure I'm understanding the question. MOVIE is of type array of Movie. What's to inherit?
Sorry. I dont have much knowledge about this. Now I am clear that it is a array, but can you teach me a alternative way on replacing the using with something else. I mean I dont want to use using in my code. Can you let me know a alternative way on doing this code.
maybe you want this:
movie MOVIE[MAXMOVIES];
but it is a global variable where you have it -- this really belongs down inside main or something.

slightly better is to use vector but it may be going beyond what you have studied so far
std::vector<movie> MOVIE(MAXMOVIES); //need #include<vector>

Last edited on
 
std::vector<Movie> movies;


This is my code guys. I tried with the way you guys tought me but its giving some error. Can you guys let me know a way?

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

using MOVIE = Movie[MAXMOVIES];

int ReadFile(MOVIE& movies, int& movieCount)
{
    string file_name = "Movies.txt";  // <--- Put File name here.
    int i;
    ifstream movies_file("Movies.txt");

    if (!movies_file){
        cout << "\n File " << "\"" << file_name << "\"" << " did not open." << endl;
    }

    while (getline(movies_file, movies[i].name, '|')){
        getline(movies_file, movies[i].day, '|');
        getline(movies_file, movies[i].time1, '|');
        getline(movies_file, movies[i].time2, '|');
        getline(movies_file, movies[i].time3);
        movies_file.clear();

        i++;
    }

    movieCount = i;

    return 0;
}

update_movie()
{
    fstream movie, temp;
    int lines, movieCount{}, readStatus{};
    char selection_movie1, name [25], time1[25], time2[25], time3[25];
    movie.open("Movies.txt",ios::in);
    temp.open("temp.txt",ios::out);

    MOVIE movies;
    if (readStatus = ReadFile(movies, movieCount))
        return readStatus;
    showmovielist(movies, movieCount);

    cin.ignore();
    cout << endl;
    cout << "Enter the serial number of the movie that you want to update [1,2,3...]: ";
    cin >> selection_movie1;

    char count = '0';
    string line;

    ifstream file("Movies.txt");
    while (!file.eof())
    {
        getline(file, line);
        count++;
    }

    lines = count - 50 ;

    while((selection_movie1 <= '0') || (selection_movie1 > count))
    {
        cout << endl;
        cout << "Sorry! You have entered a wrong selection. Please try again." << endl << endl;
        cout << "Please select a movie: ";
        cin.ignore(std::numeric_limits <std::streamsize>::max(), '\n');
        cin >> selection_movie1;
    }

    selection_movie = (selection_movie1 - 48);

    cout << endl;

    int i = 0;
    while(i++ , i <= count)
    {
        movie.getline(name,25,'|');
        movie.getline(time1,25,'|');
        movie.getline(time2,25,'|');
        movie.getline(time3,25);

        if (i == selection_movie)
        {
            int time[3] = {}, x = 0;
            cout << " Enter the time for First show  (HHMM): ";
            cin >> time[0];
            time_checking(time, x);
            i = 1;

            cout << " \nEnter the time for Second show (HHMM): ";
            cin >> time[1];
            time_checking(time, x);
            i = 2;

            cout << "\n Enter the time for Third show  (HHMM): ";
            cin >> time[2];
            time_checking(time, x);
            temp << name << '|' << time[0] << '|' << time[1] << '|' << time[2] << '\n';
        }

        else
        {
            temp << name << '|' << time1 << '|' << time2 << '|' << time3 << '\n';
        }

    }
    temp.close();
    movie.close();

    movie.open("Movies.txt",ios::out);
    temp.open("temp.txt",ios::in);

    int y = 0;
    do
    {
        temp.getline(name,25,'|');
        temp.getline(time1,25,'|');
        temp.getline(time2,25,'|');
        temp.getline(time3,25);
        movie << name << '|' << time1 << '|' << time2 << '|' << time3 << '\n';
        y = y + 1;
    }while (y <= lines);

    temp.close();
    movie.close();

    cout << "\n You have done editing the showtime manager!!! \n";
    remove("temp.txt");
}
What error? It's also useful if you provide a complete program that can just be compiled without having to work out what #includes are needed, the main() function etc.
My code is quite long, so I provide the link to my google docs. You can just copy the whole code from there. Thank you for your help

https://docs.google.com/document/d/1dE7UYO7UOjFjcdBQGmB4F33b7dxDyqgLNO5Y6_xKJD8/edit?usp=sharing
I did not download your code, but I did take a glance at it.

One thing you can not do is call main() recursively.
1
2
3
4
5
 if (reuse_response == 'y' ){
        char seat_row = 0,seat_column = 0,response = 0,seat_type = 0,MTRS_response = 0 ;
        system("CLS");
        main();           // <- NOT ALLOWED
    }


Edit: Have you even tried to compile this? I get lots of errors when I do.
I would concentrate on fixing the errors before worrying about eliminating the using.

 
#include <string>         // <- Missing 


Many of your functions are missing a return type specifier. In C, the compiler will assume int, but in C++ the return type specifier is required.

Don't use goto. Goto's lead to spaghetti code which is hard to follow.

Line 741: You have a \ in front of the WELCOME.

You should break your program up into one class declaration per .h file and one class implementation per .cpp file and one .cpp file for main.
Last edited on
Registered users can post here. Sign in or register to post.