Write a program that gets names as input from the user

Assignment Help Programming Languages
Reference no: EM13763396

To learn about pointers, dynamic memory allocation and data structures managed by pointers.

Assignment-

name (string)

best_friend (Person *), a pointer to a persons best friend

popularity (int), a popularity counter that indicates how many other people have this person as their best friend.

Then write a program that gets names as input from the user (Read from the console using cin. You may tell the user to enter a name or q to quit entering names.) , allocates a new Person for each of them and stores the pointer to each of them in a vector. Then ask the user for the name of the best friend for each of the Person objects. Locate the object matching the friend's name and call a set_best_fiend method to update the best_friend pointer and the popularity counter. Finally, print out all Person objects , listing the name, best friend and popularity counter for each.

Other instructions

The main difficulty in this program is that you are dealing with pointers to Person objects. You are not directly dealing with Person objects. Keep this in mind as you write your code. Before you access any pointer, make sure it is not NULL. Write if statements as necessary to test for this. A persons popularity goes up if they are someones best friend. If you have a best friend that does not increase YOUR popularity. You need to write all necessary member functions for the class.

Note: This is not an assignment about separate compilation. You may write everything into the file hw9.cpp including your class declaration and definition.

Reference no: EM13763396

Questions Cloud

Calculate the conventional b/c ratios : Calculate the conventional b/c ratios for alternate a. is alternate aeconomically justified and calculate the modified b/c ratio for alternate a. is alternate a economically justified?
Application of years-of-service method : Ace Inc. has five employees participating in its defined-benefit pension plan. Expected years of future service for these employees at the beginning of 2014 are as follows.
Problem related to forest ecosystem : Identify the risks and benefits of extracting or using one type of nonrenewable and one type of renewable energy resource from that ecosystem.
Write paper on need for affiliation emphasizes establishment : Write a paper that need for affiliation emphasizes the establishment and nurturing of intimate relationships with other people.
Write a program that gets names as input from the user : Write a program that gets names as input from the user (Read from the console using cin. You may tell the user to enter a name or q to quit entering names.), allocates a new Person for each of them and stores the pointer to each of them in a vecto..
Calculate cost of goods sold : How would you calculate cost of goods sold? What items make up cost of goods sold?
Issue of recreation specialist : WHY are these mostimportant? HOW would you integrate them into Mecklenburg Park and Recreation?
Discuss closing entries and reversing entries : Discuss closing entries and reversing entries. Discuss the steps in the accounting process.
Compute the cost of a single unit of product : Compute the cost of a single unit of product under boththe absorption costing and variable costing approaches.? Prepare an income statement for the year using absorption costing.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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