<< Chapter < Page Chapter >> Page >
  • x, y coordinates
  • a constructor with two parameters representing x, y coordinates (their default values are allowed to be 0)
  • a member function named display, which prints out two coordinates on the screen.
  • A member function named getInfo, which accepts two input data from the user for x, y coordinates.
  • Two member functions named setX, setY to update values to x, y, respectively.
  • Two member functions named getX, getY to retrieve values from x, y, respectively.
  • A member function named distance, which accepts as parameter an object of class CPoint and calculates the distance from the object invoking the function to the parameter object.

b. Construct a derived class named CPoint_3D from the class CPoint, described as follows:

  • There is one more data member: coordinate z.
  • There are overriding member functions in CPoint_3D for all corresponding member functions in the class CPoint.

c. Include the class constructed in a) and b) in a working C++ program. Have your program call all of the member functions in the CPoint_3D class.

Programming project topic examples

Project 1

This project aims to review all the chapters from Chapter 1 (Introduction to Computers and Programming) to Chapter 6 (Functions and Pointers) which focus on structured programming.

An example of Project 1 can be described as follows:

The Colossus Airlines fleet consists of one plane with a seating capacity of 12. It makes one flight daily. Write a seating reservation program with the following features:

  • The program uses an array of 12 structures. Each structure should hold a seat identification number, a marker that indicates whether the seat is assigned and the name of the seat holder. Assume that the name of a customer is not more than 20 characters long.
  • The program displays the following menu with six choices:
    • Show the number of empty seats
    • Show the list of empty seats.
    • Show the list of customers together with their seat numbers in the order of the seat numbers
    • Assign a customer to a seat
    • Remove a seat assignment
    • Quit
  • The program successfully executes the promises of its menu. Choices (4) and (5) need additional input from the user which is done inside the respective functions.
  • After executing a particular function, the program shows the menu again, except for choice (6).

Project 2

This project aims to review all the chapters from Chapter 7 (Introduction to Classes) to Chapter 8 (Object Manipulation - Inheritance) which focus on the basics of object-oriented programming.

An example of Project 2 can be described as follows:

A stack is an ordered collection of data items in which access is possible only at one end, called the top of the stack with the following basic operations:

  • Push: add an element to the top of the stack.
  • Pop: remove and return the top element of the stack.
  • Check if the stack is empty
  • Check if the stack is full.

It would be nice to have a stack class, because we could then use it to easily develop some applications which need stack data structure.

For the moment, assume that we need to define an integer stack class. Since a stack must stores a collection of integers, we can use an integer array to model the stack and a “pointer” named Top to indicate the location of the top of the stack. The array should have a fixed size. So we can begin the declaration of the class by selection two data members:

  • Provide an integer array data member to hold the stack elements (the size of the array is a constant).
  • Provide an integer data member to indicate the top of the stack.

As for the member functions of the stack class, we have to define 5 member functions: the constructor which creates an empty stack and four other member functions (push, pop, check if the stack is empty, check if the stack is full).

After defining the stack class, write a main() function which does the following tasks:

  • Creating one stack object.
  • Pushing into the stack object ten integer elements which take values from 1 to 10 with the increment of 1.
  • Popping one by one element from the stack object and displaying it out, repeating this action until the stack becomes empty.

Next, apply the stack data structure in solving the following problem: write a program that accepts a string from the user and prints the string backward. (Hint: Use a character stack)

Questions & Answers

Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
yes that's correct
I think
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
scanning tunneling microscope
how nano science is used for hydrophobicity
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
what is differents between GO and RGO?
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
analytical skills graphene is prepared to kill any type viruses .
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
The nanotechnology is as new science, to scale nanometric
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
what school?
biomolecules are e building blocks of every organics and inorganic materials.
anyone know any internet site where one can find nanotechnology papers?
Damian Reply
sciencedirect big data base
Introduction about quantum dots in nanotechnology
Praveena Reply
what does nano mean?
Anassong Reply
nano basically means 10^(-9). nanometer is a unit to measure length.
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!

Source:  OpenStax, Programming fundamentals in c++. OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10788/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals in c++' conversation and receive update notifications?