<< 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

how can chip be made from sand
Eke Reply
are nano particles real
Missy Reply
Hello, if I study Physics teacher in bachelor, can I study Nanotechnology in master?
Lale Reply
no can't
where we get a research paper on Nano chemistry....?
Maira Reply
nanopartical of organic/inorganic / physical chemistry , pdf / thesis / review
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
Application of nanotechnology in medicine
has a lot of application modern world
what is variations in raman spectra for nanomaterials
Jyoti Reply
ya I also want to know the raman spectra
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
Nasa has use it in the 60's, copper as water purification in the moon travel.
nanocopper obvius
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 .
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
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
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now

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?