answersLogoWhite

0


Best Answer

Constructors are functions that you use to define (initialize) the properties and methods of a class. By definition, constructors are functions within a class definition that have the same name as the class. For example, the following code defines a Circle class and implements a constructor function: // file Circle.as class Circle { private var circumference:Number; // constructor function Circle(radius:Number){ this.circumference = 2 * Math.PI * radius; } } The term constructor is also used when you create (instantiate) an object based on a particular class. The following statements are calls to the constructor functions for the built-in Array class and the custom Circle class: var my_array:Array = new Array(); var my_circle:Circle = new Circle(9);

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

C is not an object oriented programming language. Even if it were, you cannot have a virtual constructor. Only destructors can be virtual.

In C++, which is object oriented, a constructor is used to instantiate an object of a class. All objects must be constructed from the ground up, from the least-derived class to the most-derived class. This is done automatically.

Declaring a method virtual forces the most-derived override of that method to take precedence. This is exactly what we want during destruction because we cannot destroy a base class object until we have destroyed all its derivatives -- the exact opposite of construction. Thus when designing base classes we must declare the destructor virtual. If we don't, we will end up with an invalid derivative should a base class object be forced out of scope before its derivatives, as can happen if we delete a pointer to the base class object. With a virtual destructor, the most-derived class would be destroyed first, even if we did not know its exact type at compile time. The object's virtual table ensures the correct method is invoked at runtime.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are constructors and deconstructors in C programming language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

When was C - programming language - created?

C - programming language - was created in 1972.


What programming language is Android written in?

Android is programmed in the C and C++ programming language.


Name of object oriented programming language?

C++ is the name of a programming language.


What do you mean by c language?

C is a programming language.


Example of procedural programming language and object oriented programming language?

example of procedural programming are those programming language that have structure e.g basic,fortran,c++,c and pascal e.t.c


Websites to download c C programming language books?

Download 1000s of C C C++ Programming Language. http://www.guruengineers.com


Who are the ancestors of C programming language?

programming languages B and BCPL which was used to derive C


Why is programming language named C and not simply C?

I am guessing you typed the question wrong, the way I understand your question is "Why is the programming language named C++ and not C ? " The answer to this is that there is a programming language called C, and in that programming language the ++ means increment by one. So C++ is the language C improved, as such it can read and compile all C programs in addition to having other features that C does not have.


What is a programming language and with three example?

A programming language is a language in which a human can tell a machine to do something, three examples include: C, C++ and C#.


What programming language is PHP made with?

PHP is written in the C programming language.


What is the C language used for?

Programming.


What programming language is similar to C?

c++