answersLogoWhite

0

How many constructors can c have?

Updated: 8/9/2023
User Avatar

Wiki User

12y ago

Best Answer

A class can have any number of constructors, as far as they are having different parameters or different number of parameters. For example, a class A can have following constructors & even more:

A() -the default constructor

A(A objectA) -the copy constructor

A(int p)

A(int p1, int p2)

A(int[] p1, float p2)

A(double p1, double p2, int p3)

A(A objA, int[] p)

A(B objB)

User Avatar

Wiki User

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

Wiki User

12y ago

Constructors are a C++ topic, so there are no constructors in C.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

6

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How many constructors can c have?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


What is the difference between default constructor and parameterized constructor?

A default constructor is one that has no parameters (C++ also calls constructors with all default parameters a default constructor), while a parameterized constructor is one that has at least one parameter without a default value. Default constructors can be provided by the compiler if no other constructors are defined for that class or any class the class inherits from, while parameterized constructors must always be defined by the developer.


What is a constructor with value zero?

Constructors have no value, zero or otherwise. That is, constructors cannot return a value. This is because constructors are not functions in the sense you cannot call a constructor directly. Constructors are invoked in the background when you instantiate an object of the class, thus any return value would be lost in the background, and would therefore not be visible to the invokee.


What is overloading constructor in java?

This is when you overload the constructor so that there isn't just one way you can initialize the class objectAssume you have a class called Foo and you want two different constructorsFoo(int a, int b);Foo(float a, float b);using a method like this can make your classes more dynamic and you don't need to to write a new class to handle different types. Sorry for the lack of Java code, i program in C++ but it you can overload functions and constructors in C++ too.


What is the Difference between virtual methods and non virtual methods in c sharp?

A function is a method that returns a value other than void. Methods includes functions, subroutines, constructors, destructors, and properties.

Related questions

What are different type of constructor in java?

Every class, including abstract classes, MUST have a constructor. The different types are: a. Regular constructors b. Overloaded constructors and c. Private constructors


How many constructors does class Exception have?

The Exception class has 4 constructors. They are: a. Exception() b. Exception(String arg) c. Exception(String arg, Throwable arg1) d. Exception(Throwable arg)


What is copy constructor in java?

Java, unlike C++ does not support copy constructors.


What is the difference between default constructor and parameterized constructor?

A default constructor is one that has no parameters (C++ also calls constructors with all default parameters a default constructor), while a parameterized constructor is one that has at least one parameter without a default value. Default constructors can be provided by the compiler if no other constructors are defined for that class or any class the class inherits from, while parameterized constructors must always be defined by the developer.


For what purpose constructors are used in Java?

Constructors are used to create the instance of a class.


When was Worshipful Company of Constructors created?

Worshipful Company of Constructors was created in 1985.


Are constructors inherited?

Constructors, static initializers, and instance initializers are not members and therefore are not inherited.


What actors and actresses appeared in Constructors - 2013?

The cast of Constructors - 2013 includes: Rauf Khabibullin as Rauf


How can a constructor be invoked at the time of inheritance in C Plus Plus?

It cannot. Inheritance is a compile-time operation. Constructors are invoked at runtime at the point of instantiation.


What are the various concepts of c plus plus?

1.Classes and Objects 2.Constructors and Destructors 3.Inheritance 4.Polymorphism 5.Dynamic Binding


What is a constructor with value zero?

Constructors have no value, zero or otherwise. That is, constructors cannot return a value. This is because constructors are not functions in the sense you cannot call a constructor directly. Constructors are invoked in the background when you instantiate an object of the class, thus any return value would be lost in the background, and would therefore not be visible to the invokee.


What is the use of constructors?

Constructors are used in object-oriented programming languages to create usable instances of abstract data types (classes).