No, it does not. Those are two different things.
The abstract
in your case is a language keyword, which is also adapted by several other OOP languages, such as PHP or C#. On the other hand, C++ does not know the abstract
keyword and instead uses a concept called pure virtual functions. It is a keyword directly related to OOP and polymorphism, making it possible to choose a valid implementation e.g. during runtime.
The other abstraction of hiding implementation details is a general programming concept, revolving around the idea that when you call some code, you shouldn’t rely on its inner workings, but on the provided API (e.g. method signature).
Given an example function to add two numbers:
public class Calculator {
public int addInts(int left, int right) {
return left + right;
}
}
you are inherently hiding the implementation detail that adding two numbers requires placing the plus (+
) symbol between them. Thanks to this, some other code may use your method without such knowledge:
int result = Calculator.addInts(10, 15);
However silly this example is regarding addition, introduction e.g. of a more complicated function, such as sqrt
for square root calculation, simplifies callers of your sqrt
method which no longer need to focus on the inner working of how a square root is calculated. Also, given a stable definition of your API (in methods analogy the input and output arguments), you could perhaps completely rework the implementation of your sqrt
method. Given the calculation would still be correct, the algorithm could suddenly be 10 times faster and the consumers of the sqrt
method would automatically benefit from this, without having to change anything (as long as the consumers of the method relied only on its input and output arguments semantics and not on the method’s inner workings).
And of course, abstraction can be applied on entire layers of software. Perhaps you have some method which loads users:
List<User> loadUsers() {
// ...
}
which internally calls a database by running a SQL statement. By introducing this method, you added a level of abstraction to shield other layers of your application from interacting with SQL directly and instead put the SQL into this method. Thanks to this you could in the future decide to store the users in a completely different way, and the users of the loadUsers
method wouldn’t be bothered by it at all, since they didn’t know anything about a SQL database in the first place.