answersLogoWhite

0


Best Answer

Depends on the language, the value of NULL (actual implementation and its value), and the definition of valid.

But in general, a pointer is an int, the value is a memory address of another data type (int, struct, or function, etc).

Because a pointer is an int, the value must be one of the integers defined.

if you have a derivative like:

#define NULL 0

then yes, NULL is a valid value for any pointer to functions

but "valid" is not the same as a "valid value". One may say "valid" means a pointer is pointing to an actual function, hence a pointer pointing to NULL is "Invalid".

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Is NULL valid for pointers to functions?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you initialise pointers in functions?

Just like any other variable. Example: char *p = NULL;


What is the difference between equals 0 and equals NULL?

NULL is for pointers, 0, for numbers


Difference between null and empty in c plus plus?

NULL is a constant with the value zero. It is typically used with pointers to signify the pointer is valid, but it does not store a valid memory address. In other words it points at nothing in particular. It is nullified. All pointers that are not currently in use must be nullified to signify the fact they are not in use. The term empty applies to arrays that have no elements: empty arrays. We also use the term when referring to empty strings. A string is simply an array of char, but while null-terminated strings always have at least one char, the null-terminator, the string itself is empty.


What is the difference between null and void pointers?

A void pointer is a pointer that has no type information attached to it.A null pointer is a pointer that points to "nothing". A null pointer can be of any type (void included, of course).


Solution to null pointer assignment error?

Answer#ifndef NULL# define NULL ((void*)0)#endifAnswerDon't use pointers that contain NULL-value. Eg:int *myptr= NULL;...*myptr = 32; /* wrong */


Java does not support pointers then what is null pointer exception?

A null pointer exception is thrown when you are trying to manipulate an object that is null. It is just the name and does not have any relevance to the pointers as in C Example: ArrayList lst = null; Object obj = lst.get(0); In the first line we have declared an array list. Without initializing it we have tried to access the element in the 0th position. This would cause a null pointer exception.


What are the advantages of pointers in a program?

A pointer is simply a variable that stores a memory address and that allows that memory to be dereferenced. Unlike a reference, which must always refer to the object assigned to it, a pointer can refer to any object of the pointer's type, including null. A null pointer is simply a pointer that does not refer to any object. In languages that do not support pass by reference (such as C), pointers must be used to pass objects to functions. The pointer is passed by value, but the value is a memory address, which is the same as passing the object at that address. In languages that do support references (such as C++), references are useful when you need to guarantee an object exists because a reference can never be null. However, when passing an object to a function as an optional parameter, you must use a pointer because pointers can be null. Programmers must test pointers to ensure they are non-null before attempting to dereference them. References do not need to be tested; if a reference exists, it must refer to an object in memory.


Which is a valid declarations of a String?

String s1=null


Pointers to review in a napolcom examination?

government functions


What is meant by passing function to another function in c plus plus?

Just as pointers can point to variables, pointers can also point to functions. Thus you can pass function pointers to functions. In so doing, you can alter the behaviour of the function by having it call dynamically call arbitrary functions rather than just preset functions.


What does the error 'Null Pointer Assignment' mean?

The null pointer assignment error means your program has attempted to access a memory address that does not belong to your program. This typically occurs when accessing memory indirectly through a pointer: int* p = nullptr; *p = 42; // Error: null pointer assignment The above is the classic example of this type of error. The null address is typically the all-zeroes address (0x0) but, regardless of the physical address, it must never be accessed because it is a system address. We typically refer pointers to the null address when they are no longer in use or we don't have an address we can (yet) assign to them. Passing unchecked pointers to functions is another common cause: void f (int* p) { *p = 42; // potential error // ... } In the above example there's no guarantee p refers to a non-system address. Although we can easily test p is non-null before accessing it, that won't guarantee p refers to a non-system address. However, we can greatly reduce the risk of error by passing memory address via references instead of pointers: void f (int& r) { r = 42; // ... } There's still potential that r refers to a system address if the address were passed via a pointer, however there is seldom any need to use unchecked pointer variables in C++. References and resource handles (or smart pointers) eliminate the need for pointers and are actually more efficient than pointers because testing for null becomes largely redundant. The only time we really need a pointer is when "no object" is a valid argument: void f (int* p) { if (p == nullptr) { // the "no object" code } else { // code that operates on an object } }


Explain in detail in a binary tree of n nodes there are n plus 1 null pointers representing children?

Induction: 1. A tree of one node has two NULL-pointers. 2. Whenever you add a node to a tree, you remove one NULL-pointer (from the parent of the new node), and add two (the child's of the new node) in the same time.