Pointers
- The pointer can point to any variable that is not declared with which of these?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
both volatile & const
- What is the output of this program?
#include
using namespace std;
int fun(void *P);
int main()
{
char *S = "Interview Mania";
fun(S);
return 0;
}
int fun(void *P)
{
cout << P;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Even though it is a void pointer, we gets the address.
- A void pointer cannot point to which of these?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
A void pointer cannot point to methods in c++ and class member in c++.
- What is the output of this program?
#include
using namespace std;
int main()
{
int *ptr;
void *vptr;
if (vptr == ptr)
{
cout << "Interview Mania";
}
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The void pointer is easily converted to any other type of pointer, so these are equal.
- When does the void pointer can be dereferenced?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
By casting the pointer to another data type, it can be dereferenced from the void pointer.