Are int, char also an Abstract Data Type?

4.2k views Asked by At

I want to know that are all primitive data types in C, C++ and Java are Abstract Data Types because their implementations are hidden.

And one more thing:

I want to ask is if an ADT has two parts of Abstract View (all the functions that can be operated on it) and implementation view (how functions and data type are implemented). Then how I can create an ADT in C++??

As in java, abstract view can be implemented using Interface while Implementation view is implemented using class.

2

There are 2 answers

3
Glenn Teitelbaum On BEST ANSWER

Think of Abstract versus Concrete (The term concrete here is mine for illustrative purposes.

An abstract class cannot be created, a concrete class can. when you inheretit from an abstract class and define all the abstract methods, it is now concrete.

since you can instantiate an int it is not abstract, but rather concrete

It is not that an implementation is hidden that makes it abstract, it is that it is is yet to be defined.

If you have an abstract base class, then some of the functionality must be defined by its children. Visibility is irrelevant. You cannot inherit from int it is a POD (plain old data) type

In C++ std::string has a visible implementation, in java, part of it is hidden (thats why + can be used to concatenate strings in Java)

0
user3774410 On

ADT is a concept that defines certain kind of operations on the data, like you can push or pop in a stack. You can implement an ADT in any language, and in any which way, but it has to have those operations in it. Int, float, strings, list, set etc all are ADTs. Now when you implement them in any language then they become concrete types. Like you can create a list in python but that would be a concrete type as there is an actual code implementation of list ADT. Whereas LIST is an abstract concept in itself which has certain operations associated with it.