LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-21-2013, 05:33 PM   #1
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Rep: Reputation: 30
stupid questions about C on which I have doubts


My questions are:
1) Stack, queue, tree are examples of abstract data types?
2) Is it possible to implement abstract data types in pure C language?
 
Old 06-21-2013, 06:28 PM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Hi there,

Quote:
Originally Posted by shifter View Post
1) Stack, queue, tree are examples of abstract data types?
yes, I would say so. These three are basic, but generic concepts of data organization. Each of these implies a certain way of how data is structured and how it can be accessed, but doesn't specify the nature of data objects being stored and handled.

Quote:
Originally Posted by shifter View Post
2) Is it possible to implement abstract data types in pure C language?
Of course it is. It is possible to implement almost anything in pure C, since it is a turing-complete language. Typically, you would define a struct type holding all the necessary meta information of a single data element, and a set of functions that deal with these data elements (in C++ you would encapsulate that in a class).

If the solution is intended to be a generic one, you will probably have to deal with a fair amount of void*, sizeof(), and various type casts, but hey, that's why C is so much fun - because it lets you do anything.

[X] Doc CPU
 
Old 06-22-2013, 03:19 AM   #3
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
Ok, thank you for answers.
Questions become doing things :-)

Last edited by shifter; 06-22-2013 at 03:20 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Questions from a new linux convert... the doubts wedgea18 Linux - Newbie 8 02-08-2006 01:47 PM
Stupid Questions zinggniz Linux - Newbie 12 10-26-2004 10:01 PM
A few stupid questions... Eyemarten Linux - Newbie 10 04-27-2004 05:07 PM
Stupid Questions - Help!!! bfloeagle Linux - General 11 07-04-2001 09:13 PM
And now,some stupid questions Dynamo Linux - Newbie 4 04-30-2001 12:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration