LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-10-2002, 08:21 AM   #16
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16

http://www.csci.csusb.edu/cs202/templates.html
"..can become any elementary data type, pointer, class, struct or enum."
If this is the line that is being referred to it actually seems to put pointers
in it's own category.

http://www.csc.uvic.ca/courses/perm_details/csc110.html
Not sure what to think about this one :-) Granted a pointer must reference
something, ie a data type, struct, or function (am I missing any?), I can see
why "Data type pointer" is used. That may be a misnomer because pointers
can also reference functions and data structures.

http://www-3.ibm.com/software/data/db2/udb/ad/v7/adg/db2a0/frame3.htm#c
"Host variables may be declared as pointers to specific data types..."
Something to do with precompiled DB2 stuff. Even the syntax is slightly
different. (If I was looking in the right spot) Not really sure this directly
applies?

Feel free to correct any above statements that are in error :-)
 
Old 09-10-2002, 10:13 AM   #17
sarin
Member
 
Registered: May 2001
Location: India, Kerala, Thrissur
Distribution: FC 7-10
Posts: 354
Blog Entries: 2

Rep: Reputation: 34
Well, I am sorry about the first one. I missed the "," in between. But The other 2 are as follows.

11.Dynamic data structures and recursion (8%)
Recursive algorithms
Recursive data types
Dynamic data structures
Data type pointer
Abstract data type list
( A place where they speak about ADTs pointer is more than enough to convey the meaning. So I believe they meant pointer is a data type.)
In IBM site, this is all that I wanted to show.
"Pointer Data Types in C and
C++"
--Sarin
 
Old 09-10-2002, 10:54 AM   #18
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16
Quote:
11.Dynamic data structures and recursion (8%)
Recursive algorithms
Recursive data types
Dynamic data structures
Data type pointer
Abstract data type list
From what I know ADTs (abstract data types) are the basic concept for OOP
(object oriented programming) but where does that fit in with pointers and
data types?

If we follow the chapter structure they present, then a "Data type pointer"
must also be considered a (dynamic) data structure, which has (so far)
been ruled out. The layout is quite confusing may possibly be incorrect.

Last edited by no2nt; 09-10-2002 at 10:58 AM.
 
Old 09-10-2002, 01:58 PM   #19
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,571

Rep: Reputation: 180Reputation: 180
Quote:
Originally posted by no2nt
As far as pointers are integers, my above quote (yes, i'm lazy; i quoted myself) still makes me think otherwise.
Pointers are integers, but they have different length on different architectures, so you may get into trouble using them as "normal" pointers.
 
Old 09-10-2002, 02:58 PM   #20
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16
Chapter 5.6 heading "Pointers are not Integers"
"The C Programming Language" - Kernighan & Ritchie

Pointers look like integers, can be (generally) used as integers, but are
still not integers. I realize what the above post is trying to get at but there
still must be a distinction.
 
Old 09-10-2002, 06:09 PM   #21
sarin
Member
 
Registered: May 2001
Location: India, Kerala, Thrissur
Distribution: FC 7-10
Posts: 354
Blog Entries: 2

Rep: Reputation: 34
Hi no2nt, I am new to OO. But as far as I know, OO tries to avoid pointers to primitive or elementry data type. Rather OO deals mostly with pointers to non primitive objects. So when looking from that view point, it is hard to believe that "data type pointer" is refering to a pointer to a (elementry) data type. The next best ( and most obvious ) meaning one can fit in there is "Pointer is a data type".

Also, no one told you that Data type pointer is a sub section of dynamic data structure. It was your own assumption. It is very much possible that they were refering to pointers while refering to dynamic allocation.

Here is one more link.
http://pweb.de.uu.net/vanacken.do/oo...DT/String.html
(See the definition of string. )

Now you will have to agree that I have come up with atleast 2 sites that go with my view. But so far you did not show me any thing convincing.

( For your old referance to K & R, there is no explicit statement by them that pointer is not a data type. I will say its some thing like saying the "the nation and the president..")

Also, I agree to the fact that pointer is not an integer. This is clear from the way a cast operator converts pointer to integer.

What ever it is, we badly need better arguments to prove our selves correct.
( Also, if you are interested, see the fortan documentation about cray pointers)
--Sarin
 
Old 09-10-2002, 11:49 PM   #22
aditya
Member
 
Registered: Aug 2002
Distribution: RH 7.x
Posts: 71

Original Poster
Rep: Reputation: 15
I think the explanation given by boku needs some examples so that it can be more understandable.
What he says is that pointers and integers are interchangable. No problem with that. But again, in most programming languages, integers and characters are also interchangable, and in fact characters just form a subset of integers. And they can also be type-casted to perform the each-others' functions. But, still 'int' and 'char' are 2 different data-types.
Let's go to the basic definition of a data-type. A data-type defines the set of rules that govern the storage required and the operations permitted on a particular sequence on 1's and 0's in the computer memory. It is this that governs that an 'int' will take 2 bytes or whatever according to that machine, and that certain operations are logical on these sequence of bits and are permitted.
Again, as we have said before, it doesn't really matter if it's a pointer to integer, or pointer to array, it occupies the same number of bytes, because it stores addresses. So, it is independent.
So, presently I am looking at 'integers and pointers' in the same way as 'integers and characters'. Both can be used interchangably, but inherently supported by the machine so that they have their own independent existense. Does that mean a pointer is a data-type?
Let's see how long I hold with this view-point ;->
 
Old 09-11-2002, 08:55 AM   #23
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16
Anyone interested in this thread may also want to read this thread I
found on comp.lang.c.

Google Link
http://groups.google.com/groups?hl=e...om%26rnum%3D81
 
Old 09-12-2002, 12:18 AM   #24
aditya
Member
 
Registered: Aug 2002
Distribution: RH 7.x
Posts: 71

Original Poster
Rep: Reputation: 15
Thumbs up

Hey hey hey,
I think it's getting a lot funnier. I always thought pointer variables always occupied the same size irrespective of whether it's pointing to an intger or another structure or whatever, because it was just an address, which is of constant length for a machine. But this site given by no2nt gives me a big big blow on my face. (or my brain).
I'm unable to understand how could a pointer pointing to different structures could occuy different lengths. The mystery seems to deepen to me.
I think we should mov to more basics of pointers then to know what they are.
 
Old 09-12-2002, 01:14 AM   #25
aditya
Member
 
Registered: Aug 2002
Distribution: RH 7.x
Posts: 71

Original Poster
Rep: Reputation: 15
I think I got hold of a good web-page. Do read it. Just the first 5-6 lines will do. The page is not reallly big, but worth reading.

http://searchdatabase.techtarget.com...211903,00.html
 
Old 09-12-2002, 06:21 AM   #26
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,571

Rep: Reputation: 180Reputation: 180
It's just a metter of definition (how you define a data type )
 
Old 09-12-2002, 06:34 AM   #27
aditya
Member
 
Registered: Aug 2002
Distribution: RH 7.x
Posts: 71

Original Poster
Rep: Reputation: 15
Wink

What I wanted to show exactly was not really the definition the data-type, but this line:

'Examples of data types are: integer, floating point unit number, character, string, and pointer.'

What could be more clear than that!!. It says that pointer IS a data-type.
 
Old 09-12-2002, 06:41 AM   #28
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,571

Rep: Reputation: 180Reputation: 180
Quote:
Originally posted by aditya
What I wanted to show exactly was not really the definition the data-type, but this line:

'Examples of data types are: integer, floating point unit number, character, string, and pointer.'

What could be more clear than that!!. It says that pointer IS a data-type.
I understand, but if you define "data type" in a different way, a pointer may not be a data type
 
Old 09-12-2002, 08:32 AM   #29
no2nt
Member
 
Registered: Aug 2001
Location: South Carolina, USA
Distribution: Redhat 8.0/Custom
Posts: 96

Rep: Reputation: 16
Quote:
Originally posted by aditya
I think I got hold of a good web-page. Do read it. Just the first 5-6 lines will do. The page is not reallly big, but worth reading.

http://searchdatabase.techtarget.com...211903,00.html
Excellent, I'm glad you posted this!
I found this site awhile back and I almost considered changing my answer
to "data type" instead of "none of these" based on what it said. But
looking closer, it does not define what programming language it is talking
about. In Pascal (oh, beautiful, sweet language) there is a pointer [data]type,
which is language defined. Unfortunately in C I still don't see a defined
datatype that is a pointer. I see pointers to data types. :-)
 
Old 09-13-2002, 12:00 AM   #30
aditya
Member
 
Registered: Aug 2002
Distribution: RH 7.x
Posts: 71

Original Poster
Rep: Reputation: 15
Ok,
but I still don't understand how could a pointer pointing to different structures or data types occuy different lengths. This I found at the site that no2nt has given.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
redeferenced pointer to incomplete type Aldair1808 Programming 1 11-28-2005 03:23 PM
list<type> how can I make type be a pointer? exodist Programming 2 06-06-2005 08:40 AM
returning data to main() via a pointer to a pointer. slzckboy Programming 3 05-30-2005 01:20 PM
ereferencing pointer to incomplete type? ams Programming 5 03-03-2005 10:32 AM
Getting an incompatible pointer type error... JStew Programming 4 03-06-2003 05:08 PM

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

All times are GMT -5. The time now is 10:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration