Sir Prachur Sharma took this quiz in class of Programming for Engineers course at Bhagwant University Rajasthan. It includes: Addition, Program, Display, Sum, Integers, Object-oriented, Programming, Constructor, Member, Function
Download Addition Program-Programming For Engineers II-Quiz Solution and more Exercises Programming for Engineers in PDF only on Docsity!
Quiz-
Solution
Write an addition program that displays the sum of two integers entered by the user in Object Oriented Programming. class myCal { public: int a,b; int sum() { return a+b; } };
Constructor
A constructor is a special member
function that has the same name as
the class. Its purpose is to ensure
that each data member is set to
sensible initial values.
Function
A function belonging to a class is called a member function.
In a class, you provide one or more member functions that are designed to perform the class's tasks.
For example, a class that represents a bank account might contain one member function to deposit money into the account, another to withdraw money from the account and a third to inquire what the current account balance is.