Buckys C++ Programming Tutorials - 52 - Inheritance

thenewboston · 473K views · 2011 · 7:56

Open on YouTube

C, C++, Rust, Go & systems languagesEducation & learningtutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as an introductory walkthrough of C++ inheritance, and several beginners cite it as the tutorial whose Mother/Daughter code they were following when they hit errors.

Recommended by 1 people across 1 different months, 2014 to 2021.

What it is

A short beginner tutorial from Bucky Roberts' thenewboston C++ series covering class inheritance, using a Mother and Daughter class example. It is episode 52 in his long-running C++ programming playlist.

What people said

Recommends meWantToLearn · 2014-01 · Stack Overflow · on “Inheritance: Selecting which base class methods to inherit”

If I am right, then what you are looking is Inheritance. Which means if A inherits B, it inherits B's methods and properties, if and only they are cleared protected or public. Check these links: [LINK] [this video]

Cites Dark Chocolate · 2017-08 · Stack Overflow · on “Base class undefined. Error C2504”

Following this tutorial( [this video] ) I encountered 4 errors on Visual Studio C++ 2017. 3 of them are the same thing and just repeat 'Mother': base class undefined in the daughter.h file. The other error reads:'sayName' is not a member of 'Daughter' Now here is the code. It is quite simple what I want the program to print...I want it to print out two lines of "What are you doing there?" If you could help me with this answer, that would be great. Thank you. For the Main file `#include "stdafx.h" #include #include"Daughter.h" #include"Mother.h" using namespace std; int main() { Mother pot; pot.sayName(); Daughter kettle; kettle.sayName(); int pause = 0; cin >> pause; } Mother.h #ifndef MOTHER_H #

Cites Dark Chocolate · 2017-08 · Stack Overflow · on “Base class undefined. Error C2504”

Thank you so much for helping me solve my problem. Is this for all Visual Studio projects? I ask this because the tutorial that I watched( [this video] ) didn't do that.

Cites taro · 2021-11 · Stack Overflow · on “VSCode builds only the main.cpp file instead of all files in the folder”

sorry I am a beginner and I am trying to run this code from this video here: [this video] Here is my code: main.cpp #include <iostream> #include "Mother.h" #include "Daughter.h" using namespace std; int main() { Mother mom; mom.sayName(); } Mother.h #ifndef MOTHER_H #define MOTHER_H class Mother { public: Mother(); void sayName(); }; #endif Mother.cpp #include <iostream> #include "Mother.h" #include "Daughter.h" using namespace std; Mother::Mother() { } void Mother::sayName() { cout << "I am a Roberts!" << endl; } Daughter.h #ifndef DAUGHTER_H #define DAUGHTER_H class Daughter { public: Daughter(); }; #endif Daughter.cpp #include <iostream> #include "Mother.h" #include "Daughter.h" using namespac