c++ - 错误 C4430 - 对象 - 类

标签 c++ visual-studio-2010 mfc

我在另一个类中创建了类 LCalculation 的对象,

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

现在我正在尝试使用它并面对这些错误。它与此对象声明有关。我只是不明白。有人可以帮忙吗?如果需要更多信息,请随时询问。



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

  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_ap​​p_calculation\mfc_ap​​p_calculationdlg.h(35):错误 C2146:语法错误:缺少“;”在标识符“m_LCalc”之前
  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_ap​​p_calculation\mfc_ap​​p_calculationdlg.h(35):错误 C4430:缺少类型说明符 - 假定为 int。注意:C++不支持default-int
  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_ap​​p_calculation\mfc_ap​​p_calculationdlg.h(35):错误 C4430:缺少类型说明符 - 假定为 int。注意:C++不支持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_ap​​p_calculation\mfc_ap​​p_calculationdlg.cpp(191):错误 C2065:“m_LCalc”:未声明的标识符
  • 1>c:\users\admin\documents\visual studio 2010\projects\Calc\mfc_ap​​p_calculation\mfc_ap​​p_calculationdlg.cpp(191):错误 C2228:“.m_Amount_of_Numbers”左侧必须有类/结构/union
    • 类型是“未知类型”





明白了,我是新来的。 @Joachim Pileborg。谢谢。

第一个标题:

// 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;

第二个标题:

// 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();
};

第三个标题:

#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);
};

最佳答案

在您的第二个 header (MFC_App_CalculationDlg.h) 中,您忘记了 #include "LCalculation.h" 或者您命名了第三个 header 。

顺便说一句,UpdateData 返回一个 BOOL,而不是 amount_of_numbers。您应该阅读 UpdateData 和 DoDataExchange 的文档,以更好地了解 MFC 如何与对话框控件进行数据交换。

关于c++ - 错误 C4430 - 对象 - 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17483960/

相关文章:

c++ - 如何使 char 数组与输入的大小相同(或者可以使用字符串库而不是 C 样式数组字符串来完成)?

c++ - MFC 文档模板中的共享处理程序预处理器指令

c++ - 创建文件 : direct write operation to raw disk "Access is denied" - Vista, Win7

c++ - 这个for循环中 "int factorial = 1"的解释

c++ - 在 WINAPI 中格式化写入文件

visual-studio-2010 - Visual Studio 2010 数据库项目 : Reference external database

c++ - 允许用户在 CStatic C++ MFC App 中绘制拖动矩形

c++ - 我应该选择什么同步方案来避免实时 C++/MFC 应用程序上的死锁?

c++ - 在 find_if 算法中将 char* 转换为 string::iterator

asp.net - 在 Visual Studio 中调整 ASP.Net 图像的大小以进行缩放