template + Inheritance.

Bros I have got into trouble,would be really happy if someone help me..

Actually I have two classes and they both are template class. How do I make inheritance btw them.

Here is class which is being inherited.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
template<class appTemp>
class application{
      protected:
      string ID;
      string plateform;
      public:
             string name;
             void display(){//The Function To Print Attributes Of Applications.
                   cout<<name<<endl;
                   cout<<ID<<endl;
                   cout<<plateform<<endl;
                           }
             application(appTemp name2,appTemp ID2,appTemp plateform2){//Making templated constructor.
                                ID=ID2;
                                plateform=plateform2;
                                name=name2;
                                }
              };


Here is another Class.
Which is making inheritance.
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
template<class appTemp>
class games:public application<appTemp>{
      string makers;
      string language;
      string genre;
      string yearOfRelease;
      string business;
      public:
            games(appTemp makers2,appTemp language2,appTemp genre2,appTemp yearOfRelease2,appTemp business2){
                             makers=makers2;
                             language=language2;
                             genre=genre2;
                             yearOfRelease=yearOfRelease2;
                             business=business2;
                             }
             void setvalue(){
                            fflush(stdin); 
                            cout<<"Enter Name Of App:";
//                            getline(cin,name);
                            cout<<"Enter ID of App:";
//                            getline(cin,ID);
                            cout<<"Enter Plateform of App:";
//                            getline(cin,plateform);
                            cout<<"Enter Genre:";
                            getline(cin,genre);
                            cout<<"Enter Year Of Release:";
                            getline(cin,yearOfRelease);
                            cout<<"Enter Business By App:";
                            getline(cin,business);
                            cout<<"Enter Makers Of Game:";
                            getline(cin,makers);
                            cout<<"Enter Language It Was Made In:";
                            getline(cin,language);
                            }
            void display(){
//                            cout<<"Name:"<<right<<name<<endl;
//                            cout<<"ID:"<<right<<ID<<endl;
//                            cout<<"PlateForm:"<<right<<plateform<<endl;
                            cout<<"Makers:"<<right<<makers<<endl;
                            cout<<"Language:"<<right<<language<<endl;
                            cout<<"Business:"<<right<<business<<endl;
                            cout<<"Genre:"<<right<<genre<<endl;
                            cout<<"Year Of Release:"<<right<<yearOfRelease<<endl;
                            }
                            };
  

I have commented the things which were in the base class for partially neglecting error, but i need to inherit them..
What is the problem? Doesn't it work?
No its not working...:-)
Tell me mistakes.
What errors do you get?
Use either this before members of the base class as, for example,

getline( cin, this->name );

or use quakified names.
instantiated from here... and it is the error under games constructor.
I'm taking a guess here.

1) thing it might be saying is that there is no constructor that is accessible to the class games template for the base template. You have no default constructor, and you do not call the 3 arg constructor from the derived class.

2) Using the template type for your string variables inside your constructor that you declare as strings for the members themselves makes no sense.
e.g. string ID; //your member declaration then in the constructor appTemp ID2, what if your Type is actually ClassComplex? (made up class)

3) Inside of your display member function of the base class, you assume that the types are strings (or there exists an overloaded<< operator for that type), why not pass to the constructor as strings?

4) Why is your base class a template at all?
Topic archived. No new replies allowed.