answersLogoWhite

0

Is class a pointer

Updated: 11/1/2022
User Avatar

Wiki User

11y ago

Best Answer

No. In computer programming, a class is a data type while a pointer is a variable that can store a memory address.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Is class a pointer
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is pointer overloading?

Pointer overloading is another name for polymorphism. You declare a class virtual and then derive some classes from it. You delare a pointer to the base class and, at run time, assign a value to that pointer that refers to any of the classes in the derivation hierarchy. Deferencing that pointer, then, will properly choose the correct method based on which type of class was used, at run time. This works because each class type that is virtual contains a static v-table of methods that is used to choose the actual method to use at run time.


When does this pointer get created?

When we call non static method with respect to class object then this pointer is created which keep the reference of that object.


What are the application of this pointer can you use this pointer in friend function justify?

The this pointer can only be used within nonstatic member functions. Friend functions are not members so they have no access to a this pointer. However, you can pass a specific instance of a class to a function via a class reference argument. To understand how friendship works, first understand that a nonstatic member function has the following properties: 1. It has private access to the class. 2. It is scoped to the class. 3. It must be invoked upon an object of the class (has a this pointer). Static member functions have the first two properties while friend functions only have the first property.


What is the Practical application of a derived class object stored in base class pointer?

If you have base class derived object pointing by base class pointer, then you have the power of run time polymorphism in your hand, which gives you the ability to call the derived class implementation of the virtual member function. If we declare the member function as virtual in base class which needs to overridden in derived class, then you can decide at run time which implementation will be called at run time.


What is the implicit name of the parameter that gets passed into the set method of class in c?

Every non-static member function has a hidden pointer parameter named this which refers to the instance of the class the function was invoked against. For a given class, C, the type of the hidden this pointer is const C* but if the function is declared const, the pointer is const C* const. When referring to any class member, m, from within any non-static member function, this->m is implied.

Related questions

Why pointer is not an object?

A pointer in itself is not an object, because it is not an instance of a class. Of course you can define a class which has only one member, which is a pointer. class Pointer { public void *ptr; }; Pointer p, q, r;


Why is it not advisable to use this pointer with static members?

It is not inadvisable, it is impossible. Static member methods do not have access to a this pointer since they are not associated with any instance. Static members are scoped to the class, not to an object (an instance of the class). Only instance members have access to the this pointer.


What is a military class 4 laser?

From what it seems, its a laser pointer.


What is pointer overloading?

Pointer overloading is another name for polymorphism. You declare a class virtual and then derive some classes from it. You delare a pointer to the base class and, at run time, assign a value to that pointer that refers to any of the classes in the derivation hierarchy. Deferencing that pointer, then, will properly choose the correct method based on which type of class was used, at run time. This works because each class type that is virtual contains a static v-table of methods that is used to choose the actual method to use at run time.


When does this pointer get created?

When we call non static method with respect to class object then this pointer is created which keep the reference of that object.


What are the application of this pointer can you use this pointer in friend function justify?

The this pointer can only be used within nonstatic member functions. Friend functions are not members so they have no access to a this pointer. However, you can pass a specific instance of a class to a function via a class reference argument. To understand how friendship works, first understand that a nonstatic member function has the following properties: 1. It has private access to the class. 2. It is scoped to the class. 3. It must be invoked upon an object of the class (has a this pointer). Static member functions have the first two properties while friend functions only have the first property.


What is a structure pointer?

A pointer is a variable that holds address information. For example, in C++, say you have a Car class and another class that can access Car. Then, declaring Car *car1 =new Car() creates a pointer to a Car object.. The variable "car1" holds an address location.


Why do you use double star '' in initializing a variable in class?

The double star (**) notation is not specific to initializing a variable in a class. It is simply a double indirect reference to an object.float myFloat; // an objectfloat *myFloatPtr; // a pointer to an objectfloat **myFloatPtrPtr; // a pointer to a pointer to an objectmyFloat = 123.456; // initialize an objectmyFloatPtr = &myFloat; // initialize a pointer to an objectmyFloatPtrPtr = myFloatPtr; // initialize a pointer to a pointer to an objectmyFloat; // refer to an object*myFloatPtr; // refer to an object through a pointer**myFloatPtrPtr; // refer to an object through a pointer to a pointer*myFloatPtrPtr; // refer to the value of the pointer to the objectDouble pointer notation is used where the caller intends that one of its own pointers need to be modified by a function call, so the address of the pointer, instead of the address of the object, is passed to the function.An example might be the use of a linked list. The caller maintains a pointer to the first node. The caller invokes functions to search, add, and remove. If those operations involve adding or deleting the first node, then the caller's pointer has to change, not the .next pointer in any of the nodes, and you need the address of the pointer to do that.


What is the Practical application of a derived class object stored in base class pointer?

If you have base class derived object pointing by base class pointer, then you have the power of run time polymorphism in your hand, which gives you the ability to call the derived class implementation of the virtual member function. If we declare the member function as virtual in base class which needs to overridden in derived class, then you can decide at run time which implementation will be called at run time.


What is the implicit name of the parameter that gets passed into the set method of class in c?

Every non-static member function has a hidden pointer parameter named this which refers to the instance of the class the function was invoked against. For a given class, C, the type of the hidden this pointer is const C* but if the function is declared const, the pointer is const C* const. When referring to any class member, m, from within any non-static member function, this->m is implied.


What is the use of keyword virtual?

New is used to dynamically allocate memory in C++. It will also call the default constructor of a class that is created with it. int *array; // First declare a pointer array = new int [5] // Allocate enough memory for a 5 element int array // To deallocate your memory when you are finished with it, you must call delete on your pointer delete[] array; myClassType *mct = new myClassType; // example for class ... delete mct; // class delete The virtual keyword means that the class has a static virtual table (vtable) containing function pointers for each type of the class. This enables polymorphism by allowing a pointer to the base class to be assigned an address of any instance of the class in the hierarchy, and then invoking a method through that pointer - which will properly choose the correct method for that class type. Virtual also ensures that the constructors and destructors are invoked in the correct order.


What is the Use of static function?

A static function is a member function that is not associated with any instance of the class; it has no this pointer.