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

class CMyApp: public CWinApp {
public:
	BOOL InitInstance();
};



class NumericOperation;  //foward declaration

class CMySkaiciuokle: public CDialog {
public:
	CMySkaiciuokle();
	virtual BOOL OnInitDialog();
protected:
	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();

	DECLARE_MESSAGE_MAP()

private:
	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{
public:
	void Add();
	void Subtract();
	void Multiply();
	void Devide();
	BOOL isReadyforRez();
	BOOL isReady1Pair();
	BOOL isReady2Pair();
private:
	std::vector<double> m_Coll;
	double m_dbRezult;
	int m_nOperationBApplied;
};

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.

Thanks for the answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.