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
Mazyrski [523]
3 years ago
6

What is a constructor? Why would you include a constructor in a class?

Computers and Technology
1 answer:
QveST [7]3 years ago
4 0

Answer:

Constructor in the class is the member function that gets into action when any new object gets created in the class ,it gets invoked. It does not have any return type and no void return.

The constructor is used in the class because there is the requirement for the initializing of the new object and then only object can do the functioning in the program.

You might be interested in
Write an algorithm that prints out all the subsets of 3 elements of a set of n elements. The elements of the set are stored in a
Ksenya-84 [330]

void Print_3_Element_Subsets(int n,const element_type S[])

{

if(n<3) // condition to check if list have less than 3 elements

{

print("No subset found");

}

for(int i =0; i < n ; i++)

{

for(int j =i+1; j < n ; j++)

{

for(int k =j+1; k < n ; k++)

{

print(S[i],S[j],S[k]);

}

}

}

}

C++ Implementation;

#include<cstdlib>

#include<time.h>

using namespace std;

int S1[5]= {1,2,3,4,5};

int n1 = 5;

int S2[2]={1,2};

int n2 = 2;

void Print_3_Element_Subsets(int n,const int S[])

{

if(n<3) // condition to check if list have less than 3 elements

{

printf("No subset found\n");

}

printf("3 Subsets are\n");

for(int i =0; i < n ; i++)

{

for(int j =i+1; j < n ; j++)

{

for(int k =j+1; k < n ; k++)

{

cout<<S[i]<<" "<<S[j]<<" "<<S[k]<<endl;

}

}

}

}

int main()

{

cout<<"Case 1"<<endl;

Print_3_Element_Subsets(n1,S1);

cout<<endl<<"Case 2"<<endl;

Print_3_Element_Subsets(n2,S2);

}

OUTPUT

Case 1

3 Subsets are

1 2 3

1 2 4

1 2 5

1 3 4

1 3 5

1 4 5

2 3 4

2 3 5

2 4 5

3 4 5

Case 2

No subset found

3 Subsets are

--------------------------------

Process exited after 0.0137 seconds with return value 0

Press any key to continue . . .

7 0
3 years ago
Which of the following is normally mutually exclusive<br> Read only files<br> Printer<br> WIFI
marin [14]

Answer:

the answer is going to be printer

5 0
2 years ago
Write a program that uses an STL List of integers. a. The program will insert two integers, 5 and 6, at the end of the list. Nex
poizon [28]

Answer:

answer:

#include <iostream>

#include<list>

using namespace std;

bool Greater(int x) { return x>3; } int main() { list<int>l; /*Declare the list of integers*/ l.push_back(5); l.push_back(6); /*Insert 5 and 6 at the end of list*/ l.push_front(1); l.push_front(2); /*Insert 1 and 2 in front of the list*/ list<int>::iterator it = l.begin(); advance(it, 2); l.insert(it, 4); /*Insert 4 at position 3*/ for(list<int>::iterator i = l.begin();i != l.end();i++) cout<< *i << " "; /*Display the list*/ cout<<endl; l.erase(it); /*Delete the element 4 inserted at position 3*/ for(list<int>::iterator i = l.begin();i != l.end();i++) cout<< *i << " "; /*Display the list*/ cout<<endl;

l.remove_if(Greater); for(list<int>::iterator i = l.begin();i != l.end();i++) cout<< *i << " ";

/*Display the list*/

cout<<endl; return 0;

}

5 0
3 years ago
Read 2 more answers
Pressing and holding the what key while dragging a corner handle of an image proportionally resizes it
sasho [114]
The left key I believe. I have a Mac so 
8 0
3 years ago
Read 2 more answers
Which set of skills must a network administrator and a systems administrator both have?
Andreyy89
I think the answer to this is A
6 0
3 years ago
Other questions:
  • A ____ is a prewritten formula that is built into excel.
    6·1 answer
  • What are the 4-bit patterns used to represent each of the characters in the string "1301"? Only represent the characters between
    14·1 answer
  • Today encoding scheme has taken over ascII by what
    5·1 answer
  • 8) The higher the drag coefficient, the_____ the car will go<br> a)Siower<br> b)Faster
    9·2 answers
  • En que se diferencia el software y el hardware
    7·2 answers
  • Which control program flow options runs to the end of the code block and resumes the break mode at the statement that follows?
    12·1 answer
  • What is a simulation?
    5·2 answers
  • It is a single strand of metal capable of transmitting power or data from one area to<br> another
    11·1 answer
  • to allow excel to change the cell references in a formula or function from row to row or column to column as you fill with it, y
    13·1 answer
  • Which of the following rules need to be followed when using variables?<br> Choose all that apply.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!