what about "using Basic class::Basic class" like that: struct B : A { using A::A; B(int a,int b) : A(a+b) {} }; which benefit we have from explicit inherit?
In case of inheritance, is it necessary to initialize all the members of parent class in it's child class, or can we skip it. for example parent class A has protected member data_a, and child class B has a member data_b. In B's constructor are we allowed to write B(int b):data_b(b){}. or is it important to mention data_a as well? thank's in advance you're awesome
SAI GANESH VUPPALA The endl() forces a new line and flushes the output stream, but there is only one output in this function and then the function terminates so everything in local scope is deleted by the default destuctor anyway. If there were more cout() calls in the function, using endl() would probably be a good idea. Nevertheless, it is harmless to include it and probably develops a good coding habit.
Hey Hritik , first thanks a lot for Watching my Videos I think I uploaded videos on all the topics you have mentioned. You Just Need to Search them on My Channel :-)
M.A.K The single colon (:) in C++ denotes a "member initialization list" and is used for 1) calling the base class constructor (as used here) and 2) for initializating member variables BEFORE the body executes. When used to initialize member variables of a class or structure, you will find it just before the opening brace, often on it's own line (but not required) to make reading the code easier. In the case in this video, the default constructor of class A was called so the initialization was implied. Had we wanted some other constructor, we would have to tell the compiler which one to use. Initialization is different from assignment. When you initialize, the object will be created and assigned in one operation, just as a default constructor assigns a zero to the data members upon creation, except in this case you are telling it to give you something other than zero. Take the following code: Foo(int num) : bar(num) //additional members to be initialized will be separated by a comma { } which does the same thing as: Foo(int num) { bar = num; } except that the first case is initialization and the second case is assignment. Initialization saves some processing and is absolutely necessary for class members which are constants or references. Maybe this video author has a video on it already (I didn't check) or perhaps he should make one for us.
Thank you so much. I got the defination of inheritance for constructor completely.
Can you please tell about access specifier in inherintance : public, private and protected ???
Thats very easy to understand, without any distraction and all doubts have been cleared at every point👍
What if we want to make the first value A's, can we do it? You said it is unnecessary but is it alright?
Great efforts 👏 well explained..
what about "using Basic class::Basic class"
like that:
struct B : A {
using A::A;
B(int a,int b) : A(a+b) {}
};
which benefit we have from explicit inherit?
A Cool method of teaching...😎
Sorry what is the syntax named as u added in "let's do some modifications here"
can you explain about multipath inheritance
I don't get y by changing for private to protected we got the answer in 45th video..?
how to pass string ??
In case of inheritance, is it necessary to initialize all the members of parent class in it's child class, or can we skip it. for example parent class A has protected member data_a, and child class B has a member data_b. In B's constructor are we allowed to write B(int b):data_b(b){}. or is it important to mention data_a as well? thank's in advance you're awesome
I didn't understood the way you passed int c in B constructor
And then :A(c) , i am completely confused with this part
Can you please explain it?
These videos are excellent, thanks!
Easy understanding
Hello this is class A is with cout
SAI GANESH VUPPALA The endl() forces a new line and flushes the output stream, but there is only one output in this function and then the function terminates so everything in local scope is deleted by the default destuctor anyway. If there were more cout() calls in the function, using endl() would probably be a good idea. Nevertheless, it is harmless to include it and probably develops a good coding habit.
I want to know more about protected, public and about private
I want to know about the pointer .
Hey Hritik , first thanks a lot for Watching my Videos
I think I uploaded videos on all the topics you have mentioned.
You Just Need to Search them on My Channel :-)
Hey, I have one doubt, what's the actual meaning of this "B() : A()" what's the : doing there? is it some sort of an operator?
M.A.K The single colon (:) in C++ denotes a "member initialization list" and is used for 1) calling the base class constructor (as used here) and 2) for initializating member variables BEFORE the body executes. When used to initialize member variables of a class or structure, you will find it just before the opening brace, often on it's own line (but not required) to make reading the code easier.
In the case in this video, the default constructor of class A was called so the initialization was implied. Had we wanted some other constructor, we would have to tell the compiler which one to use.
Initialization is different from assignment. When you initialize, the object will be created and assigned in one operation, just as a default constructor assigns a zero to the data members upon creation, except in this case you are telling it to give you something other than zero. Take the following code:
Foo(int num)
: bar(num) //additional members to be initialized will be separated by a comma
{
}
which does the same thing as:
Foo(int num)
{
bar = num;
}
except that the first case is initialization and the second case is assignment. Initialization saves some processing and is absolutely necessary for class members which are constants or references.
Maybe this video author has a video on it already (I didn't check) or perhaps he should make one for us.
Excellent
If we keep data_A as private and declare and define a display function inside class A. Then will the program run ?
Only accessible from own class.
Great effort.. Keep it up 👍
Best explaination
even the music here makes the learning more fun..
it helps me a lot
Thanks for the Vedioes
superb
Thanks SmartMobCorner
Help this channel by sharing it with your friends
Keep on watching and Keep on Learning Cool stuff :-)
Nice
veryyyyyy niceeee
output I cannot understand
gud
G 17
This was cute
holy fuck c++ is one hell of a mess. At least compared to java.