Abstraction means Giving only essential things and hiding unnecessary details.
Implementation details are often hidden away behind a more intuitive interface in abstraction, but that's not required. Abstraction is the process of matching the representation of data or algorithms to their meaning within a program. It's a method of implementing "code for the application, not the computer".
An example of abstraction is std::map<A,B>. We only care about uniquely mapping A to B and being able to perform fast lookups of B based on A. There's really no reason to know that std::map is implemented as a balanced search tree, and we certainly don't want to worry about managing the details of a search tree when we really just want a mapping.
The std::map abstraction gives us the ability to write what we meant in terms of the application rather than lower level junk that makes the computer happy and just obscures what the application is really doing. This is abstraction.
Encapsulation means binding the data members and methods together in a capsule form to avoid accidental changes to data from external users.
Encapsulation is the bundling of related algorithms and data. It's possible (and not entirely uncommon) to use encapsulation without any kind of data hiding:
struct point {
int x;
int y;
point(int x, int y);
};
struct line {
point a;
point b;
line(point a, point b);
double distance() const;
};
This bundling makes for convenient interfaces as well as simplifies the task of …