Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me learn how to compile this program. Following is the source code projectl.spp. Given the Complex class and my Stock template class, complete

image text in transcribed
image text in transcribedPlease help me learn how to compile this program.
Following is the source code projectl.spp. Given the Complex class and my Stock template class, complete the main function, and then compile, debug and test your program: C++ - project project.cpp Center project n mk Semter Wheren is the size of the stack, m is the modular of the real part and imagination part of a random complex number, and k is the number of elements displayed per line. In the main function, you need to 1. Get the values n, m, and k from the command line 2. Declare a complex number stack of size ngecraten random complex numbers and push them into the stack, meantime, display all these numbers, k numbers per line 3. Display all elements of the stack, k elements per line Student Name w Student ID projectl.cpp #include #include time.h> using namespace std; class Complex float re: floatim: 1/ complex number class W real part W imagination part public: Complex(float -0.0,float i-0.0){re rim:) Complex const Complex&crec.re: imc.im; void operator (const Complex & crec.re: imc.im: Complex operator (const return Complex-re, -im): Complex operator+(const Complex & const: Complex operator (const Complex&const: Complex operator (const Complex&) const: Complex operator (const Complex&const: friend ostream& operator class myStack! T'pur int size: int tops storage body storage size top position public myStackint): -my StackOffreepers) bool empty fretum top -1:} bool full freturn top-size-1: int getholdo return top 1:1 void push(Tv){ptr[+top :) T popOfretum ptr top-l:) void display(int): W constructor destructor empty or not full or not get number of items hold put an item on top take an item from top pop and display, mitems per line I create an empty stack myStackints) ): template myStack ptr (T) mallocsize sizes top-1: pop and display, k items per line void myStackdisplay(int k) if lempty) inth gethold: cout"Number of items popped up *

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

What is the function of the - rf option in the rm command?

Answered: 1 week ago

Question

b. What groups were most represented? Why do you think this is so?

Answered: 1 week ago