ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 :-)
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
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.
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.
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.
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
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 ;->
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.
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.
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. :-)
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.