Need a little help or explaining

Here's the part of the condition:
To create an abstract class C Digit:
Not public member variable "digit"
Features:
-for reading
-to record
Output Function outputs an output stream
- virtual function "less" for comparison of objects
2. Build a successor to CDigit
- hidden member variable
Functions
-for reading
- recording
-implementation of virtual output
-implementation of the data comparison function in the less class
Operators:
<< - displays in the specified stream
>> reads from a specified stream
int operator =
bool operator ==
3. Build a successor to CDigit
hidden member variable
constructors that are needed
Features:
-for reading
-to record
-implementation of void Output and "less"
Operators:
<<
>>
int operator = - to assign m_iExpFreq
bool operator ==

Last edited on
There are a lot of problems. Too many to mention them all. Here is the corrected version:
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
 #include <iostream>
#include <fstream>
using namespace std;

class CDigit
{
	 
protected:	int m_iDigit;//nepublichna chlen promenliva 
public: 

int GetDigit() const;//za chetene

void SetDigit(const int &val_iDigit)  
	{	m_iDigit= val_iDigit;	} //za zapis

	friend ostream& operator<<(ostream& toStream, const CDigit digit)	
	{		
		toStream<< digit.GetDigit() <<endl;
			return toStream;	} // izvejdane v izhoden potok
		
		virtual bool operator< (const CDigit &digit) 
			{	return m_iDigit < digit.GetDigit();	} //virtualna f-q za izvejdane na chisloto
	
		virtual void Output(ostream& toStream) 
	 		{ toStream<<GetDigit() << endl; } // za tursene po-malko s psevdonim
	 	
	//	virtual bool Less ( const CDigit* digit)
	//		{ return m_iDigit < digit.GetDigit();	} // za sravnenie po-malko s ukazatel
	
		virtual bool Less ( const CDigit* digit)
			{	return m_iDigit < digit->GetDigit();	}
};

class CExpected:public CDigit //nasledqvane  
{
	protected: int m_iExpFreq;
	
	//konstruktori!!!
	CExpected(const int& iExpFreq){m_iExpFreq = iExpFreq;}
	CExpected(const CExpected& st){m_iExpFreq=st.m_iExpFreq;}
	public:
	
		int GetExpected(void) const;//Missing const
		
		void SetExpected( const int &val_iExpFreq)
			{ m_iExpFreq = val_iExpFreq;	}		// za zapis
			
 			
			 void Output(ostream& toStream) 
	 		{ toStream<<GetExpected() << endl; }
			 
			 //moje i da ne raboti 
	//	bool Less ( const CDigit* digit)
	//		{ return m_iDigit < digit.GetDigit();	} // za sravnenie po-malko s ukazatel
	
	//	virtual bool Less ( const CDigit* digit)
	//		{	return m_iDigit < digit->GetDigit();	}	
		
		
		//operator <<
		friend ostream& operator<<(ostream&os , const CExpected&p)
		{
		    os<< p.m_iExpFreq;  // Wrong >>, missing p.
			return os;
	}
			
		//operator >>
		friend istream& operator>>(istream&is, CExpected&p) // Wrong const
		{	is>>p.m_iExpFreq;
			return is;}
		
		//operator ==
		bool operator==(const CExpected&p) const
		{	return m_iExpFreq==p.GetExpected();	} // Wrong =, Needs to be ==

		//operator = ?????
		
};

class CObserved:public CDigit 
{
	private: int m_iObsFreq;
	
	public:
		//konstruktori
		
		int GetObserved() const; //za chetene
		
		void SetObserved(const int &val_iObsFreq)
			{	m_iObsFreq = val_iObsFreq;	} // za zapis
		
		 void Output(ostream& toStream) 
	 		{ toStream<<GetObserved() << endl; }
			 
			 //moje i da ne raboti 
	//	bool Less ( const CDigit* digit)
	//		{ return m_iDigit < digit.GetDigit();	} // za sravnenie po-malko s ukazatel
	
	//	virtual bool Less ( const CDigit* digit)
	//		{	return m_iDigit < digit->GetDigit();	}

	//operator <<
		friend ostream& operator<<(ostream&os , const CObserved&p)
		{	os<<p.m_iObsFreq;
			return os;}
			
		//operator >>
		friend istream& operator>>(istream&is,  CObserved&p)
		{	is>>p.m_iObsFreq;
			return is;}
		
		//operator ==
		bool operator==(const CObserved&p)
		{	return m_iObsFreq==p.GetObserved();	}

		//operator = 		
};
You repeat the errors in the second class.
Topic archived. No new replies allowed.