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
Elis [28]
3 years ago
15

class secretType { public: static int count; static int z; secretType(); secretType(int a); void print(); static void incrementY

(); private: int x; static int y; }; secretType::secretType() { x = 1; } secretType::secretType(int a) { x = a; } void secretType::print() { cout << "x = " << x << ", y = " << y << "z = " << z << ", count = " << count << endl; } static void secretType::incrementY() { y++; } Consider the accompanying class and member functions definitions. How many constructors are present in the class definition?
Computers and Technology
1 answer:
DanielleElmas [232]3 years ago
5 0

Answer:

The answer to this question can be given as:

In this class definition, there are two constructors.  

Explanation:

In the class definition two constructors are different in type but first we explain constructor that can be as:

Constructor: constructor are special member functions whose task is to initialized as an object of its class.

Rule for defining constructor:

A constructor doesn’t have a return type not even void.

The name of the constructor must be the same as the class name.

A constructor is called automatically when a new instance of an object is created.

Type of constructor:

  1. default constructor.
  2. parameterized constructor.
  3. copy constructor.

In the question there are two type of constructor is used that can be given as:

default constructor:  

The constructor without any parameters is called a default constructor. This type of constructor is called automatically when a new instance of an object is created.

parametrized constructor:

In the parameterized constructor we use at least one parameter in the constructor that is called the parameterized constructor. In the parameterized constructor we can initialize each instance of the class with several values.

Example :

class AB   //define class  

{  

   String name; //define variable

   AB()   //default constructor

   {

   System.out.print("hello...");  //message.

   }

   AB(String name)  //parametrized constructor.

   {  

       this.name = name;  //holding value in name variable.

   }  

}  

class Main  //define class

{  

   public static void main (String[] args)  //main method  

   {  

   AB OB1 =new AB();   //creating class object.

   AB ob2=new AB("XYZ");

   System.out.print(ob2.name);  //print value

   }  

}

Output:

hello... XYZ

You might be interested in
Which of these are examples of a bug?
nadya68 [22]
The answer is b and c
7 0
3 years ago
If a user would like to modify margins to specific settings, users would need to select the _____ option.
RSB [31]
If a user would like to modify margins to specific settings, users would need to select the <span><u>Custom Margins</u> </span>option.
4 0
3 years ago
The full meaning of ENIAC,ABACUS,EDVAC,EDSAC<br>and explain ​
balandron [24]

Answer:

ENIAC: Electronic Numerical Integrator and Computer.

ABACUS: Abundant Beads, Addition and Calculation Utility System.

EDVAC: Electronic Discrete Variable Automatic Computer

EDSAC: Electronic Delay Storage Automatic Computer

7 0
3 years ago
Extension: Cash Register Program
Evgesh-ka [11]

Answer:

hee hee 4 you are correct

Explanation:

6 0
3 years ago
The Zootopia Police Department is recruiting new officers and has come up with an innovative equation to hire. They define hireS
Dahasolnce [82]

Answer:

#include<iostream>

#include<limits>

#include<iomanip>

using namespace std;

//function that returns true

//if there is invalid input like giving string as input

// for integer value.

bool isInvalidInput()

{

  //return true if cin.fail

  if(cin.fail())

  {

      //clear the buffer

      cin.clear();

      cin.ignore(numeric_limits<streamsize>::max(),'\n');

      return true;

  }

  return false;

}

//function that calculates the hire score for given 3 parameters.

double calHireScore(double agility,double strength,double speed)

{

  return (1.8*agility) + (2.16 * strength) + (3.24 * speed);

}

//calculate hire score for fox.

void calFoxHireScore()

{

  double agility,strength;

 

  cout<<"Enter Agility Value: ";

  //get agility as input and validate it.

  cin >> agility;

  if(isInvalidInput() || agility <= 0)

  {

      cout<<"\nError: Agility value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Strength Value: ";

  cin >> strength;

  if(isInvalidInput() || strength <= 0)

  {

      cout<<"\nError: Strength value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Fox: "<<calHireScore(agility,strength,0)<<endl;

}

//function that asks input from user for

//calculating hire score for Sloth.

void calSlothHireScore()

{

  double strength,speed;

 

  cout<<"Enter Strength Value: ";

  cin >> strength;

  if(isInvalidInput() || strength <= 0)

  {

      cout<<"\nError: Strength value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Speed Value: ";

  cin >> speed;

  if(isInvalidInput() || speed <= 0)

  {

      cout<<"\nError: Speed value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Sloth: "<<calHireScore(0,strength,speed)<<endl;

}

//function that asks input from user for

//calculating hire score for Bunny.

void calBunnyHireScore()

{

  double agility,speed;

 

  cout<<"Enter Agility Value: ";

  cin >> agility;

  if(isInvalidInput() || agility <= 0)

  {

      cout<<"\nError: Agility value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Speed Value: ";

  cin >> speed;

  if(isInvalidInput() || speed <= 0)

  {

      cout<<"\nError: Speed value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Bunny: "<<calHireScore(agility,0,speed)<<endl;

}

//function to display menu for user.

void menu()

{

  cout<<"\n1. Fox"<<endl;

  cout<<"2. Bunny"<<endl;

  cout<<"3. Sloth"<<endl;

  cout<<"0. Quit"<<endl;

  cout<<"Enter your choice: ";

}

//main method

int main()

{

  int choice;

  do

  {

      //asks choice

      menu();

      cin >> choice;

      //if invalid input print erro message

      if(isInvalidInput())

      {

          cout<<"\nError: Invalid choice enetered. Try Again\n";

      }

      else

      {

          cout<<"\n";

          //if any one of the choices do accordingly

          //for invalid choice print error mesage.

          switch(choice)

          {

              case 1:

                  calFoxHireScore();

                  break;

              case 2:

                  calBunnyHireScore();

                  break;

              case 3:

                  calSlothHireScore();

                  break;

              case 0:

                  cout<<"\nQutting...\n";

                  break;

              default:

                  cout<<"Invalid choice entered."<<endl;

                  break;

          }

      }

     

  }while(choice != 0);

 

  return 0;

}

Explanation:

3 0
3 years ago
Other questions:
  • What is requirement analysis
    8·1 answer
  • Spreadsheet software creates a ____, composed of a grid of columns and rows
    5·1 answer
  • "list at least 3 key performance indicators that should be considered prior to initiating a cloud deployment."
    15·1 answer
  • What is meant by encapsulating semaphores? Bring out the need for it
    12·1 answer
  • Write the definition of a function printDottedLine, which has no parameters and doesn't return anything. The function prints to
    10·1 answer
  • In the Programming Process which of the following is not involved in defining what the program is to do:_____________ Group of a
    10·1 answer
  • A new company will have 40 workstations in one building sharing a single network. All users must be able to share ¬les and print
    7·1 answer
  • The chief intellectual property officer (CIPO) is responsible for collecting, maintaining, and distributing the organization's k
    14·1 answer
  • What is single user operating system? Write two examples.​
    12·2 answers
  • Explain the history of computing device of mechanical era
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!