How to change from SDT to ADT

This is a discussion on How to change from SDT to ADT within the C Programming forums, part of the General Programming Boards category; How can I change a code from Structured Data Type to Abstract Data Type ? Code: typedef enum Bool{false = ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    1

    How to change from SDT to ADT

    How can I change a code from Structured Data Type to Abstract Data Type ?

    Code:
    typedef enum Bool{false = 0, true = 1} TBool; 
    typedef enum Color{red, blue, yellow, green, violet, orange} TColor; 
    TColor Mix(TColor C1, TColor C2); 
    TBool Primary(TColor C); 
    void From(TColor C, TColor *C1, TColor *C2); 
    TColor Mix(TColor C1, TColor C2){ 
    if(((C1 == red) && (C2 == yellow)) || ((C1 == yellow)&&(C2 == red))) 
    return orange; 
    else if(((C1 == red) && (C2 == blue)) || ((C1 == blue)&&(C2 == red))) 
    return violet; 
    else if(((C1 == yellow) && (C2 == blue)) || ((C1 == blue)&&(C2 == yellow))) 
    return green; 
    } 
    TBool Primary(TColor C){ 
    if((C == red)||(C == yellow)||(C == blue)) 
    return true; 
    else 
    return false; 
    } 
    void From(TColor C, TColor *C1, TColor *C2){ 
    if (C == orange) 
    *C1 = red, *C2 = yellow; 
    else if(C == green) 
    *C1 = yellow, *C2 = blue; 
    else if(C == violet) 
    *C1 = red, *C2 = blue; 
    }
    thank.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    An abstract data type is always implemented as a structured data type. Code contains only real data types/structures, not abstractions:

    Abstract data type - Wikipedia, the free encyclopedia

    "Abstract data types" are just human language descriptions for the purpose of discussion, etc.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Change log-in name...
    By $l4xklynx in forum General Discussions
    Replies: 6
    Last Post: 07-02-2009, 07:15 PM
  2. What can I add/change?
    By HelpLol in forum C++ Programming
    Replies: 0
    Last Post: 02-14-2008, 03:03 AM
  3. Where do you change your sig?
    By PЯO in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 02-09-2008, 04:13 PM
  4. plz change
    By sweet2awy in forum C++ Programming
    Replies: 4
    Last Post: 07-11-2003, 04:37 PM
  5. Replies: 2
    Last Post: 11-08-2002, 02:22 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21