1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
OLEGan [10]
3 years ago
11

Constructors are special methods included in class definitions. a. What is a constructor used for? b. How do constructors differ

from other methods in a class?
Computers and Technology
1 answer:
PIT_PIT [208]3 years ago
6 0

Answer:

(a)A constructor is a special method which is used the initialize the class that means the initialize the object of a class.

(b)There is the following difference between constructor and method in a class.

1. Constructor name has the same name as the class name we do not give any other name to the constructor, on the other hand, it is possible in function to giving any name to function.

2. The constructor does not have return type such as int, void, etc on the other hand function must have a return type.

3.constructor does not return any value on the other hand function are returning the value.

Explanation:

Following are the program of constructor in c++

#include <iostream> // header file

using namespace std; // namespace

class constructor1

{

   public:

   constructor1() // default constuctor

   {

       cout<<" hello brainly:"<<endl;  

   }

void fun() // fuuction

{

cout<< "function:";

}

};

int main() // main function

{

constructor1 ob; // creating object it call default constructor

ob.fun();//  calling the function fun()

  return 0;

}

Output:hello brainly:

function:

In this program, we create a class and create a function "fun" and "default "constructor "from the main function we create the object of a class which calls the default constructor and with the help of object we call the function fun.

You might be interested in
What would be a good hash code for a vehicle identification that is a string of numbers and letters of the form “9x9xx99x9xx9999
Hunter-Best [27]
I also want to ask a question recently i used a software named [url=http://www.videoconverterfactory.com/tips/youtube-to-flac.html]youtube to flac[/url] while after the conversion the size is to big. Why did this happen and how to solve without lose quality?
4 0
3 years ago
Full form of http.<br>wrong answer will be reported ​
vodomira [7]

Answer:

So it is Hyper Text Transfer Protocol.

Hope it helps

6 0
3 years ago
Read 2 more answers
(25 POINTS)Which statement best reflects the importance of following safety guidelines?
jeyben [28]

Answer:

I think, Every year, thousands of people die as a result of workplace injuries.

6 0
3 years ago
Read 2 more answers
Olivia wants to add buttons and clickable features to her website. Which language should she use?
Feliz [49]

B. HTML. I hope this helps!!!

8 0
3 years ago
Read 2 more answers
Does anyone know how many Brainliests you need to be able to send a private message to someone??
White raven [17]

Answer:

no idea sorry...

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Here's something to stop you from getting repetitive when writing essays. Write a program that reads multiple lines of plain tex
    15·1 answer
  • In 1–2 sentences describe how you would insert a row in a spreadsheet.
    6·2 answers
  • Ask the user to enter a number n &gt;= 1. There after the user will enter n-1 distinct integers between 1 and n. Thus, the enter
    9·1 answer
  • Jimmy and his friends are creating a rock band and have decided to turn his garage into a recording studio. He wants to sell the
    9·2 answers
  • Which grapgic element loads faster when used with text or audio
    7·1 answer
  • Write out the base sequence that is added directly after the primer. In order for Moodle to correctly grade this question, write
    11·1 answer
  • To speed up the display of graphics, a(n) ________ is integrated into some video cards. select one:
    12·1 answer
  • Technology trends in education play a key role in a student’s
    15·1 answer
  • Select three advantages of cloud computing.
    10·1 answer
  • Why does brainly want me to PAY or watch ads<br> i hate doing that
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!