Reverse Polish Notation

Hi! I'm doing this assignment and I'm stuck and dunno how to proceed. Basically I have 3 classes and I'm trying to work with complex numbers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef CRpnCalculator_H
#define CRpnCalculator_H

using namespace std;

#include "CComplex.h"

class CRpnCalculator
{
private:
	CLifoBuffer stack;

public:
	bool pushValue(CComplex const& data);
	bool popValue(CComplex const& data);
	void add();
	void subtract();
	void multiply();
	void divide();
};


#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

#ifndef CLIFOBUFFER_H_
#define CLIFOBUFFER_H_


class CLifoBuffer{

private:
	int m_size;
	int m_tos;

	CComplex* m_pBuffer;

public:

	CLifoBuffer(int size=0);
	~CLifoBuffer();
	void print();
	bool push(CComplex const& data);
	bool pop(CComplex& data);

};



#endif 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream>
#include <math.h>

using namespace std;

#ifndef CComplex_H
#define CComplex_H

class CComplex{

	friend CComplex operator+(float lOperand, CComplex const& right);
	friend CComplex operator-(float lOperand, CComplex const& right);
	friend CComplex operator*(float lOperand, CComplex const& right);
	friend CComplex operator/(float lOperand, CComplex const& right);

	friend ostream& operator<<(ostream& out, CComplex const& c);


private:
	float m_real;
	float m_imaginary;

public:
	CComplex(float real=0,float imaginary =0);
	CComplex(CComplex const& c);
	void set(float real, float imaginary);
	float abs();
	void print();

	CComplex operator+(CComplex const& rOperand);
	CComplex operator+(float rOperand);

	CComplex operator-(CComplex const& rOperand);
	CComplex operator-(float rOperand);

	CComplex operator*(CComplex const& rOperand);
	CComplex operator*(float rOperand);

	CComplex operator/(CComplex const& rOperand);
	CComplex operator/(float rOperand);

	CComplex& operator++();		//Prefix increment
	CComplex operator++(int);	//Postfix increment
};

#endif 


Can someone help me with the following question:

Implement pushValue() and popValue(). These methods delegate directly to the
corresponding methods of the stack attribute (the LIFO buffer).
What part do you need help with?
in the main() i would be using an object of the class CRpnCalculator to call the function pushValue().. now that function would be calling the push function of CLifoBuffer class. Now the problem is how do I get to assign the memory of the buffer so that when I call the pushValue() function it would push a complex number CComplex *m_pBuffer and vice versa for pop function.
Topic archived. No new replies allowed.