+ 3

What is abstraction, referring to C++, I didnt get it by only theory, Can anyone explain it with example.

And need to use abstractions, it's necessity. I studied in course. But it was unclear to me.

19th Feb 2018, 12:03 PM
Mr. Potter
Mr. Potter - avatar
5 Respostas
+ 6
oop is actually pre-arrangement of coding..before we code a main application body..we need to specify setters, getters, constructors, and toString or printing functions...so that we would code easily and code in better pattern or design.. private variables and functions cannot be accessible directly.. . private: int total; means you cannot set total like this: Adder a; a.total=10; but you can do this way: Adder a; a.addNum(10); after setting total value using addNum() now you can get total value using a.getNum(); if you declare total this way: public: int total; you can set the value this way Adder a; a.total=10; after setting value you can also get the value like this- cout<<a.total;
19th Feb 2018, 12:47 PM
Andrew Ting Mai Zau
Andrew Ting Mai Zau - avatar
+ 3
It's a good question! It's difficult to understand the practical working of abstraction by mere theory. I am curious to know what people are going to explain here. So do you want to the learn the practical working of abstraction in terms of OOP or are you specifically looking for how "C++" implement this? And have you worked on Python before?
19th Feb 2018, 12:09 PM
GeekyShacklebolt
GeekyShacklebolt - avatar
+ 2
Hello Andrew, I got it. And now I am learning data encapsulation, it looks similar to data abstraction, they are both teaching about hiding data from public. Lol.
19th Feb 2018, 12:50 PM
Mr. Potter
Mr. Potter - avatar
+ 1
So Abhi Varshini, My point is I am asking you which data is hidden from outside world in your code; because you coded private: //hidden data from outside world int total; //Then total is outputted, so where is hidden data? This is really unclear.
19th Feb 2018, 12:14 PM
Mr. Potter
Mr. Potter - avatar
+ 1
Hello Geekybolt, I read data abstraction in C++ lessons, I went through the comments and they were just using real world examples like book, bike, PlayStation. so I asked here to know tk get some coding examples.
19th Feb 2018, 12:19 PM
Mr. Potter
Mr. Potter - avatar