Write the definition of the non parameterized constructor

Assignment Help C/C++ Programming
Reference no: EM13981209

Objective: Learn to define a class, its member functions, constructor, constructor overloading, constant member functions, and constant member of the class and how to use a reference as the function arguments.

1. Consider the definition of the following class:

class Point{
private:
 int x;
 int y;
public:
 Sample(); //Constructor 1
 Sample(int); //Constructor 2
 Sample(int, int); //Constructor 3
 void show() ;
 double calculateDistance();
};

i. Write the definition of the Non parameterized constructor (constructor1) so that the private member variables are initialized to 0.

ii. Write the definition of the parameterized constructor (constructor 2) so that the private member variable x is initialized according to the value of the parameter, and the private member variable y is initialized to 0.

iii. Write the definition of the parameterized constructor (constructors 3) so that the private member variables are initialized according to the values of the parameters.

iv. The show function is used to print the x and y value of an object.

v. The calculateDistance function is used to calculate the distance of the point from the origin.

2. Implement a class for stack of numbers using the array. Please note the operations defined for a Stack data structure are as follows:

a) Function name: push Return type: void

Purpose: It places an element in the Stack. Before place an element in the Stack you should check whether stack is full or not.

b) Function name: Pop

Return type: void

Purpose: It removes an element from the Stack. Before remove an element from the Stack you should check whether stack is empty or not.

c) Function name: isEmpty

Return type: boolean

Purpose: This function just check whether the stack is empty or not.

d) Function name: isFull

e) Return type: boolean

f) Purpose: This function just check whether the stack is full or not.

Write the main function to demonstrate all operations involving the Stack.

3. Create a class Student. Student class has the following attributes:

Student Name (character type pointer) : stRoll,
Student Roll (integer type) : stName,
Marks obtained by Student (integer type) :stMarks
and Student Year(character type pointer). :stYear

Initialize the attributes using the constructor (use the constructor overloading).

The non parameterized Constructor initialized the attributes with the following values:

Name and year is initialized with NULL. Roll and Marks is initialized by 0 and -1.

The parameterized Constructor initializes the attributes with the given value as arguments.The other functions are:

Function name: display
Return type: void.

Purpose: It displays the attributes of the object and each information is printed in the new line. The function declaration should assure that it does not change any attributes.

Function Name: displayRollName
Return type: Student

Purpose: It prints the roll and name of the student.

Function Name: find Max
Return type: Student

Purpose: It identifies the student who scored the highest marks.

You may add any other functions in your representation as required.

Create a Student Object using Non parameterized Constructor.

Create the two student using parameterized Constructor and then print the student name and roll number who scored highest marks 

Reference no: EM13981209

Questions Cloud

History of emergency medical service system : Write a 4-page essay based on the history of emergency medical service system
What distance does water land from the bottom of the cup : A plastic cup, 15.0 cm in height, is filled to the rim with water. A small hole is punctured in the cup at a height 9.00 cm above the bottom of the cup and is allowing water to spew out. At what distance does the water land from the bottom of the ..
Find the electric flux through the surface : A spherical surface completely surrounds a collection of charges. Find the electric flux through the surface if the collection consists of the following charges.
What is the magnitude of the centripetal acceleration : A plastic disk of radius 10 cm is spinning at 120 rpm. What is the magnitude of the centripetal acceleration of the outer rim of the disk?
Write the definition of the non parameterized constructor : Write the definition of the Non parameterized constructor (constructor1) so that the private member variables are initialized to 0. Write the definition of the parameterized constructor (constructor 2) so that the private member variable x is initial..
Construct the rate diagram for this ctmc : Construct the rate diagram for this CTMC. Make sure to clearly define your states.
Essay - incorporating technology into classrooms : Crossing borders: incorporating technology into classrooms - The the focus of the forum is yo explore the relevance and benefits, challenges and opportunities of using technology to teach foundation programs.
Find the electric potential at point p1 on the axis : A plastic rod of length L = 0.115 m and uniform positive charge Q = 305. pC lying on an x axis. With V = 0 at infinity, find the electric potential at point P1 on the axis, at distance d = 0.0530 m from one end of the rod.
What is balls diameter when its temperature is raised : What is its diameter when its temperature is raised to 105.0oC? What temperature change is required to increase its volume by 0.800%?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Evaluates statements of an expression language

Completing and extending the C++ program that evaluates statements of an expression language.

  Create a c++ function named pathexists

Write a C++ function named pathExists that determines whether or not a there's a path from start to finish in a 10x10 maze. A 2-dimensional 10x10 character array of Xs and dots that represents the maze. Each 'X' represents a wall, and each '.' rep..

  Write a program in which the program prints out

Use (switch statement) to write a program in which the program prints out the input (single character) if the character is not '2','t', or 'w'. Use 'default' and 'break' wisely.

  Write a c program that will calculate the gross pay

Write a C program that will calculate the gross pay of a set of employees. For each employee the program should prompt the user to enter the clock number, wage rate, and number of hours as shown below.

  Compute square roots to a desired degree of accuracy

write a program which will compute square roots to a desired degree of accuracy.

  Android activity program

Design an app with a single activity that shows the following information about that activity every time that activity is visible to the user. This information should be shown in the layout of that activity

  Elements that must be included in a loop

What are the three elements that must be included in a loop in order for the loop to successfully perform correctly - What will happen if these statements are not included? Provide examples.

  Write a fraction class whose objects will represent fraction

Write a fraction class whose objects will represent fractions. You should provide the following member functions: Two constructors, a default constructor which assigns the value 0 to the fraction, and a constructor that takes two parameters

  Create your own function that accepts one input parameter

Create your own function that accepts one input parameter and returns a float number. You decide the theme. You should provide the pseudocode and an example call. Be sure to provide an overview of what your function is doing.

  Where is the error in this code sequence?

Where is the error in this code sequence?Explain what the problems are and how to fix them.

  Write a main function that reads pairs of positive integers

Prepare a function that has two positive integer parameters (say high and low) that returns the number of powers of two between (but not equal to) those parameters.

  Rewrite a c++ program

I have Assign in C++ , I create evrething but my project not work also Iput it all documents.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd