0
What is abstraction in c++ how to use it with code? What is encapsulation in c++ and how to use it in code?
Am I thinking right that abstraction and encapsulation is public and private keywords. If I am not right can you explain me and give ao examples?
15 ответов
+ 1
It will just make you understand better the concept of virtual functions.
+ 1
not object but background for abstraction.
You will see exactly what it does in the lesson about inheritance and abstraction.
+ 1
no problem. have a good day:)
0
abstraction is like override the base class methon.
You can do that with the virtual keyword.
Here is an example:
https://code.sololearn.com/cHbutFyUWr6A/?ref=app
encapsulation is to make a variable private to use it and to make it private after use it.
0
Here is for encapsulation:
https://code.sololearn.com/c9Y0891mhyAo/?ref=app
0
Dror Dahari Thank you now I know what encapsulation means but I dont know what abstraction means. And are abstraction and envapsulations using with public and private keywords?
0
let's say you have a function named "hello"(void type) in your base class(base class is for inheritance)
now lets say you don't want to create another function over and over again.
the solution is Abstraction.
You can use the same function over and over again without creating a new function.
class Base
{
public:
void virtual hello() { }
};
class Child : public Base
{
public:
void hello() //you use the same function name
{
cout << "hello";
}
}
//in the main you call those functions.
//you can add now how many classes as you want that inherit from Base and use the SAME function.
0
I dont learned inheritanse so I dont get it. Can you explain me in more aimple words. And I still dont get what is public and private because I thing they are encapsulation keywords.
0
If you didn't learned inheritance it's not important don't worry about that now:)
0
Dror Dahari Thanks but why abstraction is before inheritanse?
0
Is SoloLearn will learn this again?
0
And can tou give me just basic understand of abstraction?
0
actually I don't have somthing basic for that because there is literally nothing to do with that at this stage.
But just understand that is just for reusable code.
0
Dror Dahari Thanks you, in leason said something about give basic view of object without any backroind details?
0
Thanks : )