Sign In
Ask Question
Jayla Bryant
Computers & Technology
17 October, 11:40
What is the purpose of a constructor?
+5
Answers (
1
)
Nico Gallegos
17 October, 11:45
0
The main purpose of the constructor in the computer science is to initialize the object of the class. The constructor is basically called after the allocation of the memory in the object. When the object is created, the constructor are basically used to initialize as default value.
Constructor is also known as special type of the member function. The compiler called the constructor whenever the object has been create and the construction has similar name of the given class.
Example:
Class test () {
int p, r; / / variable declaration
public:
/ / constructor
/ / Assigning value in the constructor
p=5;
r=10;
Cout<<" Constructor value/n";
}
Comment
Complaint
Link
Know the Answer?
Answer
Not Sure About the Answer?
Find an answer to your question 👍
“What is the purpose of a constructor? ...”
in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers
You Might be Interested in
What material is lighter to use for a wheel aluminum or magnesium
Answers (1)
Alicia spends all day at work on the Internet and then all night on social networking sites looking at the many interesting things her friends have been doing.
Answers (1)
In the lab, you discovered that the server you scanned (10.20.1.2) was vulnerable to the WannaCry ransomeware attack.
Answers (1)
You are on vacation and want to see where all the restaurants and trendy shops are in relation to your hotel. You remember there is an app on your phone that will use your location and show you that information. What is the app using?
Answers (1)
You can use automatic link-checking software to identify invalid hyperlinks. if you find invalid links, what should you do next?
Answers (1)
New Questions in Computers & Technology
You are trying to troubleshoot a desktop power supply issue using a voltmeter. Which of the following options are the MOST common voltages produced by the power supply? (Select TWO). (Select all that apply.
Answers (1)
What is a surrogate key, and under what circumstances would you use one?
Answers (1)
When a system is configured to allow booting to different operating systems at startup, what is this called?
Answers (1)
What is objective reporting? Reporting that separates fact and opinion Reporting that explains the writer's opinion Reporting that tells incorrect facts Reporting that is no longer used in America
Answers (1)
Assume that dataTransmitter is a variable that refers to an object that provides a method, named sendObject. There is one argument for this method, a reference to a Customer object.
Answers (1)
Home
»
Computers & Technology
» What is the purpose of a constructor?
Sign In
Sign Up
Forgot Password?