+ 1

Using Inheritance in C++

Create two classes Teacher and MathsTeacher, where Teacher has one public member called CollegeName. The class MathsTeacher inherits publicly from Teacher and has members mainSubject and TeacherName. Write a C++ program that uses inheritance. (You may include constructor or setter method)

13th Jul 2018, 12:17 PM
Vincent Alulu
Vincent Alulu - avatar
13 Réponses
+ 1
1.) Use curly braces for class 2.) Use them also in the second class 3.) Don't forget the semicolon ; after variables. 4.) Why are you setting everything to void? Think about the structure again and what type of variables you need (int, double, char, string..) I suggest you to go through the tutorial again.
13th Jul 2018, 2:54 PM
Matthias
Matthias - avatar
23rd Jul 2018, 7:23 AM
Femi
Femi - avatar
0
Show your efforts!
13th Jul 2018, 12:24 PM
Nikhil Dhama
Nikhil Dhama - avatar
0
I already did!! And since I'm having problems doing so that's why am asking
13th Jul 2018, 12:29 PM
Vincent Alulu
Vincent Alulu - avatar
0
Vincent Alulu can we have a look what you had done?
13th Jul 2018, 12:33 PM
Nikhil Dhama
Nikhil Dhama - avatar
0
you can post your code into the playground section, and then copy-paste it's link here, in case you don't know.
13th Jul 2018, 12:33 PM
Nikhil Dhama
Nikhil Dhama - avatar
0
Okay give me a minute
13th Jul 2018, 12:34 PM
Vincent Alulu
Vincent Alulu - avatar
0
#include <iostream> using namespace std; class Teacher( public: void collegeName() ); class MathsTeacher: public Teacher public: void mainSubject void TeacherName int main() { return 0; }
13th Jul 2018, 12:59 PM
Vincent Alulu
Vincent Alulu - avatar
0
Can anyone help me through the whole thing??
13th Jul 2018, 12:59 PM
Vincent Alulu
Vincent Alulu - avatar
0
class Teacher { public: char* collegeName(); }; class MathsTeacher: public Teacher { public: char* mainSubject; char* TeacherName; }; int main() { return 0; }
13th Jul 2018, 8:59 PM
Bebida Roja
Bebida Roja - avatar
0
Thanks Bebida Roja hope you can answer the other questions I posted too🙏🏿🙏🏿 Please!!
13th Jul 2018, 9:32 PM
Vincent Alulu
Vincent Alulu - avatar
0
Just click on my account profile and you will see the last four questions I posted🙏🏿
13th Jul 2018, 9:42 PM
Vincent Alulu
Vincent Alulu - avatar
- 1
Hey Bebida Roja Please help me out with the other three questions too🙏🏿🙏🏿
18th Jul 2018, 11:13 AM
Vincent Alulu
Vincent Alulu - avatar