bartleby
search
close search
Hit Return to see all results
close solutoin list

Chapter 3, Problem 3.5E

BuyFindarrow_forward

C++ How to Program (10th Edition)

10th Edition
Paul J. Deitel + 1 other
ISBN: 9780134448237

Solutions

Chapter
Section
BuyFindarrow_forward

C++ How to Program (10th Edition)

10th Edition
Paul J. Deitel + 1 other
ISBN: 9780134448237
To determine

Program Plan:

Default Constructor:

Constructor is the first function which is automatically called by the compiler when object is created. Its main purpose is make initializations for the class. Default constructors are the one which take no arguments or parameters, and even if they have parameters, they have default value. By default value we mean initial blank value which variable can take.

Syntax
Classname();
Classname(datatype=default value);
Example

Let us see following example:
#include<iostream>
using namespace std;
class A
{
int x;
float y;

public:

A(){};

// default constructor
voiddisp()
{
cout<<"\nx = "<<x;
cout<<"\ny = "<<y;
}
};

int main()
{
A a;

// making object of class A
a.disp();

// call to disp() function
}
Output

Explanation

Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

The Answers to Your Study Problems

Solve them all with bartleby. Boost your grades with guidance from subject experts covering thousands of textbooks. All for just $2.99 for your first month and only $4.99/month after? Done and done.

Get A's ASAP

Additional Computer Science Solutions

Find more solutions based on key concepts

Show solutions add

Sorry about that. What wasn’t helpful?

Q & A

Ask our subject matter experts virtually any homework help question and they’ll send you an answer within 48 hours.

0 / 5,000

We deeply value honesty and integrity. Learn about our honor code arrow_forward