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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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