0
votes

I created a object of the class LCalculation in another class,

class LCalculation
{
    public:
        unsigned __int64 m_Amount_of_Numbers;
        [...]
};

now I'm trying to use it and face those errors. It has something to do with this object declaration. I just don't get it. Could anyone help with this ? If more information is needed, feel free to ask.



class CMFC_App_CalculationDlg : public CDialogEx
{
private:
    LCalculation m_LCalc;
};

  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_app_calculation\mfc_app_calculationdlg.h(35): error C2146: syntax error : missing ';' before identifier 'm_LCalc'
  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_app_calculation\mfc_app_calculationdlg.h(35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_app_calculation\mfc_app_calculationdlg.h(35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

void CMFC_App_Calculation::OnEnChangeEdit2()
{
    m_LCalc.m_Amount_of_Numbers = UpdateData(TRUE);
}

  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_app_calculation\mfc_app_calculationdlg.cpp(191): error C2065: 'm_LCalc' : undeclared identifier
  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_app_calculation\mfc_app_calculationdlg.cpp(191): error C2228: left of '.m_Amount_of_Numbers' must have class/struct/union
    • type is ''unknown-type''





Get it, I'm new here. @Joachim Pileborg. Thanks.

First header:

// MFC_App_Calculation.h : main header file for the PROJECT_NAME application
//

#pragma once

#ifndef __AFXWIN_H__
    #error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"       // main symbols


// CMFC_App_CalculationApp:
// See MFC_App_Calculation.cpp for the implementation of this class
//

class CMFC_App_CalculationApp : public CWinApp
{
public:
    CMFC_App_CalculationApp();

// Overrides
public:
    virtual BOOL InitInstance();

// Implementation

    DECLARE_MESSAGE_MAP()
};

extern CMFC_App_CalculationApp theApp;

Second header:

// MFC_App_CalculationDlg.h : header file
//

#pragma once


// CMFC_App_CalculationDlg dialog
class CMFC_App_CalculationDlg : public CDialogEx
{
// Construction
public:
    CMFC_App_CalculationDlg(CWnd* pParent = NULL);  // standard constructor

// Dialog Data
    enum { IDD = IDD_MFC_APP_CALCULATION_DIALOG };

    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support


// Implementation
protected:
    HICON m_hIcon;

    // Generated message map functions
    virtual BOOL OnInitDialog();
    afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
    afx_msg void OnPaint();
    afx_msg HCURSOR OnQueryDragIcon();
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedRadio1();
    afx_msg void OnBnClickedRadio2();
private:
    LCalculation m_LCalc;
public:
    afx_msg void OnEnChangeEdit2();
};

Third header:

#pragma once
/*Comments*/
class LCalculation
{
    public:
        unsigned __int64 m_Amount_of_Numbers;
        unsigned __int64 m_Amount_of_Guesses;
        unsigned __int64 m_Probability;
        LCalculation ();
        bool m_bEqual;
        void CalculateThis ();
        void SZ_true ();
        void SZ_false ();
        void NUMBERequals (unsigned __int64 NUMBERS, unsigned __int64 GUESSES, unsigned __int16 IDENTIFIER);
};
1
Do you include the header file that defines LCalcultation in the header file that defines CMFC_App_CalculationDlg? - Frédéric Hamidi
Can you please post the complete and unedited error messages? And also point out where in the source you have those errors.Also, what is m_LottoBerechnung? - Some programmer dude
Also, check your semicolons before the declaration of m_LottoBerechnung. It seems you are simply missing a couple. - Some programmer dude
This is the correct unedited Error code... - Blacktempel
I'm not missing any semicolon, btw. It simply says I have to put one between LCalculation m_LCalc;. - Blacktempel

1 Answers

2
votes

In your second header (MFC_App_CalculationDlg.h) you forgot to #include "LCalculation.h" or however you named the third header.

And BTW, UpdateData returns a BOOL, not an amount_of_numbers. You should read the documentation for UpdateData and DoDataExchange to better understand how MFC is doing data exchange from/to dialog controls.