Click here to Skip to main content
15,892,809 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Accessing HDD drive Pin
JudyL_MD19-Apr-20 4:31
JudyL_MD19-Apr-20 4:31 
Questionvoid type Pin
Calin Negru10-Apr-20 22:20
Calin Negru10-Apr-20 22:20 
AnswerRe: void type Pin
Richard MacCutchan10-Apr-20 22:25
mveRichard MacCutchan10-Apr-20 22:25 
GeneralRe: void type Pin
Calin Negru10-Apr-20 22:44
Calin Negru10-Apr-20 22:44 
GeneralRe: void type Pin
Richard MacCutchan10-Apr-20 23:18
mveRichard MacCutchan10-Apr-20 23:18 
GeneralRe: void type Pin
kalberts11-Apr-20 1:22
kalberts11-Apr-20 1:22 
GeneralRe: void type Pin
Calin Negru11-Apr-20 10:25
Calin Negru11-Apr-20 10:25 
GeneralRe: void type Pin
kalberts11-Apr-20 11:36
kalberts11-Apr-20 11:36 
What else would it be? In C, a pointer is an address, nothing more.

In other languages, such as C#, a reference is a the memory address of an object, comparable to a struct, containing not only the values of the members, but also a pointer to another struct, the class object, with pointers to the various member functions. Also in C#, an array reference is a pointer to a "struct" providing the index limit of the array. If you go back to good old Pascal. any string was headed by its length, any array by fields indicating its upper and lower index limits.

Not so with C. For reasons of space efficiency, space couldn't be wasted on such.

If you are programming in C++, a pointer to a class instance is similar: It points to a struct augmented by a reference to a class object (which may in turn have a pointer to a superclass object, with a pointer to an even superer object, and so on up to the very object class with all the attributes common to all objects. When you call a method for some bottom layer object, a search through this hierarchy is made to find method pointer. For virtual methods defined at a high/intermediate level, a pointer may be found at a lower level that where the virtual function is defined, and different (sub)class objects may provide different pointers to their respective implementations of the virtual functions. Static members at various levels of subclassing may be located in the class objects, common to all subclasses.

If you implement an array in C++ as class with an array member, you may of course store the maximum index as another class member and route all accesses through a member function verifying that no access violates the index limit. Roughly speaking, you could say that that's what happening in C# (or good old Pascal). But both for "performance" reasons (don't make any hard tests! You'd be disappointed!) and for backwards compatibility with classical C, an array name is nothing but a pointer (where you don't have to write the *), and a pointer, whether an array name or an explicit one (requiring a * for dereferencing) is nothing but a memory address.

Oldtimers remember the BASIC functions PEEK(address) and POKE(address) for reading/writing any value at 'address'. I am not sure that C compilers of today allow you to read/write the "array element" at 0[address]. In my student days they did. I certainly hope that they do not today... But then again, there is nothing in the C syntax rules prohibiting it, so why shouldn't you use it?

GeneralRe: void type Pin
Richard MacCutchan11-Apr-20 23:40
mveRichard MacCutchan11-Apr-20 23:40 
GeneralRe: void type Pin
kalberts11-Apr-20 12:01
kalberts11-Apr-20 12:01 
GeneralRe: void type Pin
Greg Utas12-Apr-20 0:20
professionalGreg Utas12-Apr-20 0:20 
GeneralRe: void type Pin
leon de boer11-Apr-20 21:51
leon de boer11-Apr-20 21:51 
GeneralRe: void type Pin
Calin Negru11-Apr-20 21:47
Calin Negru11-Apr-20 21:47 
QuestionHow do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 5:57
PotatoSoup6-Apr-20 5:57 
AnswerRe: How do I add listboxes to a back buffer and use that? Pin
Richard MacCutchan6-Apr-20 6:21
mveRichard MacCutchan6-Apr-20 6:21 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 6:46
PotatoSoup6-Apr-20 6:46 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Richard MacCutchan6-Apr-20 7:04
mveRichard MacCutchan6-Apr-20 7:04 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 7:26
PotatoSoup6-Apr-20 7:26 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov6-Apr-20 8:24
Victor Nijegorodov6-Apr-20 8:24 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 8:43
PotatoSoup6-Apr-20 8:43 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
Victor Nijegorodov6-Apr-20 8:49
Victor Nijegorodov6-Apr-20 8:49 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:07
PotatoSoup6-Apr-20 11:07 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
leon de boer6-Apr-20 21:06
leon de boer6-Apr-20 21:06 
SuggestionRe: How do I add listboxes to a back buffer and use that? Pin
David Crow6-Apr-20 8:59
David Crow6-Apr-20 8:59 
GeneralRe: How do I add listboxes to a back buffer and use that? Pin
PotatoSoup6-Apr-20 11:31
PotatoSoup6-Apr-20 11:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.