Not really, but you can have:
- a pointer pointing to a structure (FILE * is an example)
- a pointer pointing to a structure-member (eg: struct tm tm; int *ip= &tm.tm_year)
- a structure-member that is a pointer (any type)
Example:
typedef struct TreeNode {
struct TreeNode *left, *right;
int data;
} TreeNode;
TreeNode *root = (TreeNode *)calloc (sizeof (TreeNode), 1);
Accessing data by address. Some data-structures, like lists and trees, are usually implemented using pointers.
C++ is related to C, the language from which it is derived.
A pointer is simply a variable that can store a memory address and has the same purpose in both languages. The only real difference is that C++ pointers can point at objects (instances of a class) and indirectly invoke their methods, whereas pointers in C (which is not object oriented) cannot.
A pointer is simply a variable that stores a memory address. Thus a pointer to an object is simply a variable that stores the memory address of an object. Since pointers are variables, they require memory of their own. Pointers may also be constant, which simply means you cannot change what they point to. Pointers can also be dereferenced to provide indirect access to the memory they point to -- hence they are known as pointers. However, unlike C, pointers are not the same as references. In C++, a reference is simply an alias for a memory address and requires no storage of its own.
See related links, below.
Java doesn't have pointers. C++ has pointers.
Nothing.
Structures in C and C++ differ in that C structures do not have an automatic typdef associated with them.
No.
They mostly deal with pointers and new operators in memory.
You can either use references or you can simply return the result by value. Note that in C++, unlike C, references are not the same as pointers. C++ references are aliases, alternate names for existing objects, whereas pointers are just variables that may contain a memory address that can be dereferenced.
Accessing data by address. Some data-structures, like lists and trees, are usually implemented using pointers.
Yes. All string variables are pointers as are other arrays.
C++ is related to C, the language from which it is derived.
A pointer is simply a variable that can store a memory address and has the same purpose in both languages. The only real difference is that C++ pointers can point at objects (instances of a class) and indirectly invoke their methods, whereas pointers in C (which is not object oriented) cannot.
if while switch
No, all functions must be defined outside of C structures. However, all functions in C have a type (the return type) and an identity (an address), so you can define function pointers as members of a structure to achieve the same end.