Sign In
Ask Question
Computers & Technology
Emerson Yates
10 February, 09:01
What is the purpose of a constructor?
+1
Answers (
1
)
Evelin Morrow
10 February, 10:57
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?
Get an answer to your question ✅
“What is the purpose of a constructor? ...”
in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers
You Might be Interested in
Which network service would you use to get the ip address from the fqdn hostname?
Answers (1)
Let's suppose you have two primary tasks for your computer: 1. You want to play online video games like World of Warcraft or Halo where knowledge of exactly where you are and where your opponents are is critical at all times. 2.
No Answers
How did the term radio originate? A. from the electromagnetic rays that the device transmits B. from the material used to create the device C. from the radial manner in which the signals transmit D.
Answers (1)
Your manager has asked you to implement a wired network infrastructure that will accommodate failed connections. You don't have a larger budget, so you decide to provide redundancy for only a handful of critical devices.
Answers (1)
Amy has decided to use a dark background and light colored text for her prensentation. Which toolbar option will let her change the color of the text? A. Text box B. Line color C. Font color D. Fill color
Answers (1)
New Questions in Computers & Technology
What is the output of the following code? int * p; int x; x = 12; p = & x; cout << x << ", "; * p = 81; cout << * p << endl;
Answers (1)
What are at least two similarities and two differences between IPv4 and IPv6?
Answers (1)
Which option describes how to apply a left indent to a selected paragraph? Press Ctrl+M on your keyboard to insert a left indent. Drag the left indent marker on the ruler to create a left indent.
Answers (1)
Which windows component can be used to display information such as weather forecasts?
Answers (1)
in java A retail company must file a monthly sales tax report listing the total sales for the month and the amount of state and county sales tax collected. The state sales tax rate is 4 percent and the county sales tax rate is 2 percent.
Answers (1)
Home
»
Computers & Technology
» What is the purpose of a constructor?
Sign In
Sign Up
Forgot Password?