Hi I am getting an error saying that a class doesnt exist even I did foward declaration:

class CMyApp: public CWinApp {
	BOOL InitInstance();

class NumericOperation;  //foward declaration

class CMySkaiciuokle: public CDialog {
	virtual BOOL OnInitDialog();
	virtual void OnCancel();
	virtual void PostNcDestroy();

	afx_msg void OnPaint();
	afx_msg void OnDigit(UINT);
	afx_msg void OnAdd();
	afx_msg void OnSubtract();
	afx_msg void OnDivide();
	afx_msg void OnMultiply();
	afx_msg void OnCE();
	afx_msg void OnClear();
	afx_msg void OnDecimal();
	afx_msg void OnPercent();


	CString m_strAritmeticDspl;
	CString m_strCurrentDspl;
	BOOL m_bErrorFlag;
	BOOL m_bDecimalString;
	BOOL m_bOperation;
	void DisplayXRegiter();
	void UpdateDisplay(CString&);

	float m_flNumber;
	std::vector<double> fl_coll;
	CRect m_rect;
	CSize m_sizeChar;
	CFont m_fontNumbers;
	NumericOperation m_NumOp; //at this point I am getting the error

	void CreateDlgFont(LPCTSTR,int);

class NumericOperation{
	void Add();
	void Subtract();
	void Multiply();
	void Devide();
	BOOL isReadyforRez();
	BOOL isReady1Pair();
	BOOL isReady2Pair();
	std::vector<double> m_Coll;
	double m_dbRezult;
	int m_nOperationBApplied;
5 Years
Discussion Span
Last Post by cppgangster

Your error doesn't say that NumericOperation does not exist. The error says that, at line 47, there is an "illegal use of an incomplete type". Forward declarations don't allow you to use the type/class directly, it allows you to use complete types which are related to that forward-declared type. Pointers and references are complete types, so you can use a pointer or reference to an object of the forward-declared type, but not an object of the forward-declared type because that type is not complete yet. That's just the way it is, you need to redesign such that you either don't need the forward-declaration or that have a data member of type NumericOperation in your other class (or store it via a pointer to a dynamically allocated object). From the looks of your code, I see no reason why the declaration of NumericOperation cannot be put before the declaration of CMySkaiciuokle.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.