+1 (315) 557-6473 

Create a Program to Implement Portfolios in C++ Assignment Solution.


Write a program to implement portfolios in C++.

Requirements and Specifications

C++ Programming Assignment 7
Classes are getting to be more realistic with each programming assignment. This assignment includes the valuable aspect of inheritance to facilitate reuse of code and operator overloading to allow the usage of familiar operators tailored specifically to the Stocks, Bonds, and Securities classes.
The objective of this assignment is to demonstrate an ability to implement inheritance and overload operators in a program.
You are working for a financial advisor who creates portfolios of financial securities for his clients. A portfolio is a conglomeration of various financial assets, such as stocks and bonds, that together create a balanced collection of investments.
When the financial advisor makes a purchase of securities on behalf of a client, a single transaction can include multiple shares of stock or multiple bonds.
For example:
Client-A purchases 100 shares of IBM $1 par value common stock on Jan. 20, 2020, for a total purchase price of $10,000 USD. Dividends for the year have been declared at $5 per share of common.
Client-A purchases 5 bonds is1sued by Intel Corporation with a face value of $1000 per bond and a stated interest rate of 7.5% on Jan 3, 2020, for a total purchase price of $5,000 USD. The bonds mature on Dec. 31, 2025.
It is your job to create an object-oriented application that will allow the financial advisor to maintain the portfolios for his/her clients. You will need to create several classes to maintain this information: Security, Stock, Bond, Portfolio, and Date.
The characteristics of stocks and bonds in a portfolio are shown below:
Purchase date (Date)Purchase date (Date)
Purchase price (double)Purchase price (double)
Quantity purchased (int)Quantity purchased (int)
Ticker symbol (string)Issuer (string)
Par value (int)Face value (int)
Stock type (i.e. Common or Preferred) (enum)Stated interest rate (double)
Dividends per share (double)Maturity date (Date)
Several of the data members above require the use of dates. Strings will not be acceptable substitutes for date fields.
Source Code
#ifndef portfolio_h
#define portfolio_h
#include "stock.h"
#include "bond.h"
using namespace std;
// Create a portfolio that holds stocks and bonds
class Portfolio
// Create a portfolio
name = "";
// Initialize the name
void setName(const string &name)
this->name = name;
// Return the name
string getName() const
return name;
// Allow adding of stock
void addSecurity(const Stock &stock)
// Add a bond
void addSecurity(const Bond &bond)
// Display the contents of the portfolio
friend ostream& operator << (ostream &output, Portfolio &portfolio)
if (!portfolio.stocks.empty())
// Sort the stocks
sort(portfolio.stocks.begin(), portfolio.stocks.end());
output << "These are the STOCKS in your " << portfolio.name << " portfolio:" << endl;
for (unsigned i = 0; i < portfolio.stocks.size(); i++)
output << portfolio.stocks[i] << endl;
if (!portfolio.bonds.empty())
//Sort the bonds
sort(portfolio.bonds.begin(), portfolio.bonds.end());
output << "These are the BONDS in your " << portfolio.name << " portfolio:" << endl;
for (unsigned i = 0; i < portfolio.bonds.size(); i++)
output << portfolio.bonds[i] << endl;
return output;
string name;
vector stocks;
vector bonds;