Join Our WhatsApp Group Join Subscribe Now!

Object Oriented Programming Using C++(313304) Practical No.10: Write programs for Default Constructor Answer

Object Oriented Programming Using C++(313304) Practical No.10

 Object Oriented Programming Using C++(313304) Practical No.10: Write programs for Default Constructor Answer

The classes and objects help to represent real-life entities with different attributes and related member functions. The use of constructor functions facilitates the initialization of instance variables.

Object Oriented Programming Using C++(313304) Practical No.10


Constructor: Constructors are special member functions that perform the initialization of every object. The Compiler calls the Constructor whenever an object is created. Constructors initialize values to instance variables after storage is allocated to the object. Constructors are of three types :

1. Default Constructor
2. Parameterized Constructor
3. Copy Constructor

 Object Oriented Programming Using C++(313304) Exercise:

1. WAP to implement default constructor that initializes num1 and num2 as 10 and 20 and prints the values of num1 and num2.

Answer:

oop


2. Define a class student that contains member variables as roll no,name and course. Write a program using a constructor as "Computer Engineering" for course . Accept this data for objects of the class and display the data.

Answer:

Practical Related Questions

1. WAP to declare a class student having data members as name and percentage. Write a constructor to initialize these data members. Accept and display data for one object.

Answer:



2. WAP to declare class time having data members as hrs, min, sec. Write a constructor to accept data and display for two objects.

Answer:


3. Complete the following table:

Answer:


Conclusion

We completed Object Oriented Programming Using C++(313304) Practical No.10 in which we wrote various C++ programs for Default Constructor.

About the Author

Hi everyone, I'm Suraj Diware, and I'm passionate about helping students succeed in MSBTE programs. This blog is dedicated to providing clear and concise explanations of MSBTE curriculum topics, along with practical tips and resources to sup…

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.