Thread: What are abstract data types

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    18

    What are abstract data types

    Hi!


    Can anybody tell me about abstract data types in C++ with example and how they differ from

    normal data types.

    I will be very thankful...

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Jan 2005
    Location
    Estonia
    Posts
    131
    I am not sure of my definition of abstract data types, but here's something on it:

    http://g.oswego.edu/dl/libg++paper/libg++/node2.html

    Wikipedia also offers a nice definition: http://en.wikipedia.org/wiki/Abstract_data_types
    Programming is a form of art.

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    40
    Google/Wikipedia are your friends for questions like this.

    Think of ADTs as a more object oriented / organized way of representing data throughout your program.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    9
    Think of a room. Your room might have a table, a bookshelf, your computer, walls, lighting, etc , but the actual "room" isnt a single physical object, its an abstract idea. Another common example of this is if you have a shape. You might draw a triangle, circle, quadrilateral etc, but you cant simply draw just a shape because we have categorized them. So, while we have an abstract idea of shapes, there is no concrete, simple shape. Basically, its a way of organizing/storing/moving a general category of data rather than the specific data itself.
    Last edited by goldz; 01-03-2007 at 03:53 AM.

  5. #5
    Registered User
    Join Date
    Feb 2006
    Posts
    312
    To my mind, an "abstract" data type is labelled as such because of the behaviour it models rather than the actual data which it holds.

    For example, in C++, we have containers such as queues, stacks and vectors. There's a good chance that in all 3 cases, the actual data is stored in exactly the same way! (no guarantees though). However, what should be striking when you read any reference or tutorial about these abstract types is that the behaviour associated with them are all fundamentally different.

    - a queue, is a first-in, first-out structure - so you would usually insert an object, or a data item at the back, and retrieve one from the front
    - a stack is a first-in, last-out structure - so you would insert objects to the 'top' and retrieve them from the 'top'
    - a vector works more like a more versatile array, with random access.


    Compare this with built in types - for built-in types, the focus is on the sort of data they hold. Their behaviour is more of a set of simple constraints, such as being unable to store a float or double inside an int, and the way the data is represented when you print it on to the console screen. eg.
    - an 'int' is called as such because it holds a whole 'integer' number
    - a 'float' is called as such, because it holds a "floating point" (real) number
    - a 'bool' is called as such, because it holds a boolean 'true/false' value.

    Unlike Abstract Data Types (ADTs) None of these constraints for built-in types really specify ways in which the data may be used - The amount of abstraction associated with these types is minimal.
    Last edited by Bench82; 01-04-2007 at 10:48 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extending basic data types.
    By nempo in forum C++ Programming
    Replies: 23
    Last Post: 09-25-2007, 03:28 PM
  2. Errors
    By Rhidian in forum C Programming
    Replies: 10
    Last Post: 04-04-2005, 12:22 PM
  3. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  4. Implementing opaque abstract data types?
    By Adock in forum C Programming
    Replies: 3
    Last Post: 04-27-2002, 06:49 AM
  5. Using enumerated data types
    By SXO in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2001, 06:26 PM