Question
In C++ Task Overator overloading Described below is a simple UML diagram for the tome class. This is the class that will be used to
In C++
Task Overator overloading
Described below is a simple UML diagram for the tome class. This is the class that will
be used to overload a number of operators so that managing the archive will be easier.
tome
-references: string [10]
-tomeName: string
-author: string
-spellsStored:int
----------------------------
+tome(name:string, tomeSize:int,author:string)
+tome(name:string, tomeSize:int,author:string, initialList:string *)
+~tome()
+getTomeSize():int
+getSpell(i:int) const:string
+getReferences(): string *
+getName():string
+getAuthor():string
+operator+(add:tome &):tome
+friend operator<<(output:ostream &,t:const tome &):ostream &
+operator=(oldTome:const tome &):void
The class variables are described as follows:
references: A array of string names that represent the names of spells that reside in
the tome. Each is a separate spell.
tomeName: The name of the tome as a string. Examples include "The Magisterial
Cookbook" and "Eye of Newt & Other Curses"
author: The name of the original author(s) of the tome as represented by a string.
spellsStored: the number of spells, out of a total of 10, currently stored in the tome.
The class methods and their behaviour is described as follows:
tome(name:string, tomeSize:int,author:string): This constructor receives a number
of arguments and instantiates them in the class.
tome(name:string, tomeSize:int,author:string, initialList:string *): The class con-
structor. It will receive a number of arguments and then instantiate all of the class
variables.
tome: The class destructor with a default behaviour.
getTomeSize: Returns the number of spells stored in the tome.
getSpell: This accepts an array index and returns the spell stored at the index.
getName: This returns the tome name.
getReferences: Returns the list of spells kept in the tome.
getAuthor: Returns the name of the author(s) of the tome.
operator+: This operator will enable two tomes to be added together. If A and
B are tomes, then C=A+B should combine all of the spells contained in A and
all in B into a bigger list and store them in C. Additionally, the authors of both
tomes must be present as well with each author after the rst, appearing with a
comma separating them. Finally, the name of the tome is taken as the name of
the component tome with the larger list of spells. If the two are equal, simply take
the rst tome then. Note that the new tome created should still remain even if the
component tomes are deleted. The most a tome can hold is 10 so you can assume
that tomes created in this way will not add tomes whose spell counts equal more
than 10.
operator<<: This is an overload of the outstream operator. When called on a tome,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started