code of abstraction in c++

Abstraction in C++ involves hiding the internal implementation details of a class/object and only exposing the necessary details to the user. This helps in simplifying the complexity of the code and promoting reusability.

Here is an example of a code snippet demonstrating abstraction in C++:

```cpp
#include <iostream>
using namespace std;

// Abstract class
class Shape {
public:
virtual void draw() = 0; // Pure virtual function
};

// Concrete class
class Circle : public Shape {
public:
void draw() {
cout << "Drawing a circle" << endl;
}
};

// Concrete class
class Rectangle : public Shape {
public:
void draw() {
cout << "Drawing a rectangle" << endl;
}
};

int main() {
Shape *shape1 = new Circle();
Shape *shape2 = new Rectangle();

shape1->draw();
shape2->draw();

return 0;
}
```

In the above code, the `Shape` class is an abstract class with a pure virtual function `draw()`. This function is meant to be overridden by concrete classes like `Circle` and `Rectangle`. The `main()` function demonstrates how objects of concrete classes are created using pointers of the abstract class type and then calling the `draw()` function on them.

Abstraction allows the user to work with higher-level concepts and functionalities without being concerned with the implementation details, thus promoting encapsulation and modularity in the code.