Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this program and I am having some trouble compiling it into C++ and trying to understand what to put in the main function.

I have this program and I am having some trouble compiling it into C++ and trying to understand what to put in the main function.

Here is the question, and I have already set up the program except the main function. And also, I have gotten an error on it.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Following is the source code projectl.cpp. Given the Complex class and my Stack template class, complete the main function, and then compile, debug and test your program: C++ -o project project.cpp Center projectlnm k cember Wheren is the size of the stack, m is the modular or the real part and imagination part of a random complex number, and number of elements displayed per line. In the main function, you need to is the 1. Get the values in, m, and k from the command line Declare a complex number stack of siren, gencraten random complex numbers and push them into the stack, meantime, display all these numbers, k numbers per line Display all elements of the stack, k elements per line 3. 5 #include #include #include 8 using namespace std; 10 class Complex { float re; float im; //Complex number class //real part //imagination part public: Complex(float r=0.0, float i=0.0) {re=r; im-i;} Complex (const Complex& c) {rec.re; im=C.im; } void operator =(const Complex& c){re=c.re; im=c.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*ptr; int size; int top; //storage body //storage size //top position //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 73 public: myStack(int); myStack() {free(ptr);} bool empty() {return top == -1;} bool full() {return top == size-1;} int gethold() {return top+1;} void push(Tv) {ptr[++top]=v;} I pop() {return ptr[top--];} void display(int); 75 }; 76 77 template myStack ::myStack(int s) { 78 ptr = (T*) malloc(s*sizeof(T); 79 size = s; top = -1; 81 } 82 83 template void myStack ::display(int k) { 84 if(!empty()) { //create an empty stack 80 //pop and display, k items per line intb - catbold . 77 template myStack ::myStack(int s) { //create an empty stack 78 ptr = (T*) malloc(s*sizeof(T)); 79 size = s; 80 top = -1; 81 } 82 83 template void myStack ::display(int k) { //pop and display, k items per line 84 if(!empty()) { 85 int h = gethold(); cout stack(n); 108 srand((unsigned) time(NULL)); 109 for(int i = 0; i stack(n); 108 srand((unsigned) time(NULL)); 109 for(int i = 0; i #include #include 8 using namespace std; 10 class Complex { float re; float im; //Complex number class //real part //imagination part public: Complex(float r=0.0, float i=0.0) {re=r; im-i;} Complex (const Complex& c) {rec.re; im=C.im; } void operator =(const Complex& c){re=c.re; im=c.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*ptr; int size; int top; //storage body //storage size //top position //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 73 public: myStack(int); myStack() {free(ptr);} bool empty() {return top == -1;} bool full() {return top == size-1;} int gethold() {return top+1;} void push(Tv) {ptr[++top]=v;} I pop() {return ptr[top--];} void display(int); 75 }; 76 77 template myStack ::myStack(int s) { 78 ptr = (T*) malloc(s*sizeof(T); 79 size = s; top = -1; 81 } 82 83 template void myStack ::display(int k) { 84 if(!empty()) { //create an empty stack 80 //pop and display, k items per line intb - catbold . 77 template myStack ::myStack(int s) { //create an empty stack 78 ptr = (T*) malloc(s*sizeof(T)); 79 size = s; 80 top = -1; 81 } 82 83 template void myStack ::display(int k) { //pop and display, k items per line 84 if(!empty()) { 85 int h = gethold(); cout stack(n); 108 srand((unsigned) time(NULL)); 109 for(int i = 0; i stack(n); 108 srand((unsigned) time(NULL)); 109 for(int i = 0; i<><><><>

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 Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions

Question

Define intercultural conflict

Answered: 1 week ago