answersLogoWhite

0


Best Answer

The C++ typeid operator returns a const-qualified lvalue object of type std::type_info, as defined in the standard library header.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What operator takes an object a reference or a pointer and returns a reference to global const object of type typeinfo?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Which is the unary operator used to dereference a pointer and return the value stored in it?

The asterisk (*) operator dereferences a pointer and returns the value stored in the memory pointed to by the pointer.


What is the purpose of the this operator?

The 'this' pointer is not an operator, it is a special pointer that exists within every instance of a class, and always points to the current instance of that class. It can only be used in non-static methods of the class because static methods do not have a 'this' pointer; static methods can be called even when there is no instance of the class. Whenever an instance method refers to one of its own members (non-static members), the 'this' pointer is implied: int CMyObject::foo() { return( this->bar ); // returns the bar member of this instance. } The 'this' pointer also makes it possible for an instance to compare itself to other instance references (often to ensure they are different instances) as well as to return a reference to itself. The assignment operator cannot be implemented any other way: CMyObject& CMyObject::operator= (const CMyObject & rhs ) { if( this != &rhs ) // check for self-reference bar = rhs.bar; // perform assignment return( *this ); // return a reference to this instance. } The 'this' pointer also allows an instance to pass a reference or pointer to itself to external functions, including the methods of other instances of the same class.


Why pointer of constructor is made but not of destructor?

When a constructor is invoked dynamically, the new operator allocates the required memory, initialises it according to the constructor, then returns a pointer to the allocation. The destructor is invoked by deleting the pointer. It wouldn't make any sense to return a pointer from a deletion.


What is the purpose of 'this' operator in c?

Every instance of a class inherits a 'this' pointer. It always points to the instance itself. Outside of the object you must use the object's variable name to refer to the object, or instantiate a pointer to the object. But from within the object's member methods you must use the 'this' pointer which is instantiated automatically as soon as the object is constructed and falls from scope when the destructor returns. Only non-static member functions have access to the 'this' pointer. There are several uses, however the most important is when checking for self-references, particularly in the assignment operator overload. That is, any member function that accepts a reference to the same class of object should always check for self-references before attempting to mutate the instance. This is particularly important when the class "owns" memory that is dynamically allocated to it. It is also used to return a reference to the current instance from the assignment operator and from any other operator overload or function that must return a reference to the current instance (including the addition and subtraction operators). Both uses can be seen in the following stripped-down example: class MyObject { public: // Assignment operator overload.MyObject& operator= ( const MyObject & obj ){ // Self-reference check. if( this != &obj ){// Assignment code goes here... } // Return a reference to this object. return( *this ); } }; The 'this' pointer can also be used to pass a pointer (this) or reference (*this) to external functions that accept such arguments. It should also be noted that when referring to an instance member from within a non-static member function, the dereferenced 'this' pointer is implied, as in: this->[member_name] Although this usage is never required, there may be times when it can help make your code more readable, or less ambiguous, especially when a member function must handle one or more external instances of the same class.


What is the use of 'this' pointer?

Every instance of a class inherits a 'this' pointer. It always points to the instance itself. Outside of the object you must use the object's variable name to refer to the object, or instantiate a pointer to the object. But from within the object's member methods you must use the 'this' pointer which is instantiated automatically as soon as the object is constructed and falls from scope when the destructor returns. Only non-static member functions have access to the 'this' pointer. There are several uses, however the most important is when checking for self-references, particularly in the assignment operator overload. That is, any member function that accepts a reference to the same class of object should always check for self-references before attempting to mutate the instance. This is particularly important when the class "owns" memory that is dynamically allocated to it. It is also used to return a reference to the current instance from the assignment operator and from any other operator overload or function that must return a reference to the current instance (including the addition and subtraction operators). Both uses can be seen in the following stripped-down example: class MyObject { public: // Assignment operator overload.MyObject& operator= ( const MyObject & obj ){ // Self-reference check. if( this != &obj ){// Assignment code goes here... } // Return a reference to this object. return( *this ); } }; The 'this' pointer can also be used to pass a pointer (this) or reference (*this) to external functions that accept such arguments. It should also be noted that when referring to an instance member from within a non-static member function, the dereferenced 'this' pointer is implied, as in: this->[member_name] Although this usage is never required, there may be times when it can help make your code more readable, or less ambiguous, especially when a member function must handle one or more external instances of the same class.


Explain the Difference between bitwise operator ' and ' and address operator ' and ' of pointer?

The bitwise logical operator and (&) calculates the bitwise logical and of two integral values. It is a binary operator.The address of (&) operator returns the address of the value to its right. It is a unary operator.The distinction between the two is one of context. The logical and operator will follow (and be preceeded by) a value, while the address of operator will follow an operator.


What is dangling pointer reference in c plus plus?

A dangling pointer (we also use the terms stray pointer and wild pointer) is created whenever we call delete on a pointer and then try to use the pointer without reassigning it.We can also create dangling pointers inadvertently by calling a rogue function that returns a pointer to an object that is local to the function we are calling. The object will fall from scope when the function returns so the pointer is left dangling.Note that there is no such thing as a dangling pointer reference. Pointers and references are not the same. A reference is merely an alias to an object -- it consumes no memory beyond the object it refers to. Whereas a pointer is a variable that may contain the address of an object, but it requires additional memory to do so (4 bytes on 32-bit architecture). Pointers may be NULL, references can never be NULL. Pointers to valid objects require indirection, references do not. References are the preferred method of accessing an object's members, not least because they are easier to work with.


What is ampersand in C Language?

The ampersand '&' has many uses in the C++ language:The single ampersand can be used to reference the pointer address of a pointer:int* pointer;int* anpointer;anpointer = &pointer;This example, although perhaps not valid, shows that the anpointer reference is now the same as the reference to the pointer memory address.The single ampersand can also be used to reference an object in a function:void function( int param1, int param2, int &reference );If this function were to be called, and the reference object altered within the function, the actualy object that was passed into the function would be altered.The double ampersand '&&' specifies that the left AND the right concepts must both be true before the whole statement is true. For example:if( conceptA true ){conceptC = true;}


A pointer to function which receives an int pointer and returns a float pointer?

float *(*funptr)(int *); float *fun (int *); funptr= fun;


What does of size of operator do?

The sizeof() operator returns the number of bytes allocated to the operand.


Size of operator?

The sizeof() operator returns the number of bytes required to represent its argument.


What is the Operator c plus plus?

c++ is not an operator, it is a programming language (the successor to the c programming language upon which it was based). However, if c were really an object or variable name, then ++ would be the postfix increment operator. c++ returns the value of c before incrementing c. Its counterpart, ++c, invokes the the prefix increment operator, which returns the value of c after incrementing. ++c is a convenient shorthand notation for c=c+1, which can also be written c+=1, all of which return the value of c after incrementing. c++ is also a convenient shorthand for c=c+1 or c+=1, but the return value is the original value of c, not the incremented value.