So from compiler point of view object is only pointer to variables. Methods are redifiend as generic functions with namespaces and extra variable? How does data access (public and private) is interpreter? How does it works if we inherited from other classes or double inherited?
1. How does data access (public and private) is interpreter? : It is compile time checking whether it is allowed or not? If allowed then compiled successfully otherwise fail but if compile successfully then it is just generic call to that function. 2. How does it works if we inherited from other classes or double inherited? : it works similarly again the compile time handling will happen and what ever the type of object is that function would be called. Now there is only one difference when there is a virtual functions involved, and to handle that there is another syntax. Example: class Base { int a; virtual void f(); virtuaI void g(); }; class Derived: public Base { void g(); }; // in main() Base *pc; pc->g(2); // this line will be replaced with next line (*(pc->vptr[1]) )(pc,2); Now g() is a function and its entry is there in virtual table at index 1 that's the reason it is 1 there. Now only point is what pc is holding, if it is holding Base then it's Base class virtual table and there it will find g() belongs to Base , but if pc is holding Derived then it is holding virtual table which belongs to Derived then it will be having g() as Derived::g(), then Derived g() will be called. I hope you will get it. :)
Hi, thanks for nice explanation, how compiler will deduce call for constructor to pass address of itself when object is not created yet, in other case Base::get(&b1) address of b1 is passed but how it will pass address on constructor when object is not created yet.
Sir,correct me if i am not wrong what is the use of writing void set() method in class in these code ,because you already initialized the value using parameterized constructor so I think it is no need to create set method in this code
Sir my question is when b1 object called to the constructor that time we are not passing value into that object, so, in that case default constructor has to call . but how it will be call for set function both the time for b1 and b2 object creation ?
If this is a constant pointer then how it is pointing to the different objects. I mean constant pointer should not change the values they are pointing.
The simplest example is when you want to add two integer then also you will call ADD function and when you want to add two float point number then also you will call ADD function but depending on inputs you must have two different function to handle this but generally you will keep function name as ADD. So here comes the function overloading.
C++ uses it to point to the address of the object you are dealing with in every member function of class. I have other videos on this pointer please visit them, or just search in CZcams you will get them, just search with my channel name.
@@CppNuts I hope they are at at least paying you for it! haha Every 2 minutes there was a new add. I now know more about C++ and where to buy cheaper car insurance.
You are my best teacher in C++
5:42 looking for something in-depth like this, Superb!
Thanks..
please explain 2nd use of this pointer.
2) To return reference to the calling object
You gained a subscriber ! Great Work !! really good Explained
Thanks dude!!
thank U again !!! Perfect explanation
So from compiler point of view object is only pointer to variables. Methods are redifiend as generic functions with namespaces and extra variable? How does data access (public and private) is interpreter? How does it works if we inherited from other classes or double inherited?
1. How does data access (public and private) is interpreter? : It is compile time checking whether it is allowed or not? If allowed then compiled successfully otherwise fail but if compile successfully then it is just generic call to that function.
2. How does it works if we inherited from other classes or double inherited? : it works similarly again the compile time handling will happen and what ever the type of object is that function would be called. Now there is only one difference when there is a virtual functions involved, and to handle that there is another syntax.
Example:
class Base {
int a;
virtual void f();
virtuaI void g();
};
class Derived: public Base {
void g();
};
// in main()
Base *pc;
pc->g(2); // this line will be replaced with next line
(*(pc->vptr[1]) )(pc,2);
Now g() is a function and its entry is there in virtual table at index 1 that's the reason it is 1 there. Now only point is what pc is holding, if it is holding Base then it's Base class virtual table and there it will find g() belongs to Base , but if pc is holding Derived then it is holding virtual table which belongs to Derived then it will be having g() as Derived::g(), then Derived g() will be called.
I hope you will get it. :)
Wow amazing video thank you
Thanks..
Helped thanks !!
Hi, thanks for nice explanation, how compiler will deduce call for constructor to pass address of itself when object is not created yet, in other case Base::get(&b1) address of b1 is passed but how it will pass address on constructor when object is not created yet.
great explanation! thanks
Thanks You So Much..
so use this always ?
I mean if you have to use then there is no other go.
Sir,correct me if i am not wrong what is the use of writing void set() method in class in these code ,because you already initialized the value using parameterized constructor so I think it is no need to create set method in this code
Sir my question is when b1 object called to the constructor that time we are not passing value into that object, so, in that case default constructor has to call . but how it will be call for set function both the time for b1 and b2 object creation ?
If this is a constant pointer then how it is pointing to the different objects. I mean constant pointer should not change the values they are pointing.
Sir,what should be circumstances at that time we can use function overloading???
The simplest example is when you want to add two integer then also you will call ADD function and when you want to add two float point number then also you will call ADD function but depending on inputs you must have two different function to handle this but generally you will keep function name as ADD. So here comes the function overloading.
sir please upload further concepts also ............
Yes man working on that part.. :)
hello sir , what type of coder you uses..?
Thanks man
You're welcome!
What will if we do return(*this) what this will return ?
why do we need 'this' pointer
C++ uses it to point to the address of the object you are dealing with in every member function of class.
I have other videos on this pointer please visit them, or just search in CZcams you will get them, just search with my channel name.
What is the meaning of writing
Base(int a) :x{a} {}
Base(int a) { x = a; }
Hard to stay focused when you have 50 ads in your video
Sorry but can't help here.
Its CZcams which decides how many ads should come, i just say CZcams can give ads at so and so places.
@@CppNuts I hope they are at at least paying you for it! haha Every 2 minutes there was a new add. I now know more about C++ and where to buy cheaper car insurance.
@@pdxbound81 loved the last part 😍🤣
@@CppNuts use adblocks, it will decrease the frequency of ads
Repeat after me: "Method" not "Meh turd"