【问题标题】:Error C4430 - Object - Classes错误 C4430 - 对象 - 类
【发布时间】:2013-07-03 06:23:24
【问题描述】:

我在另一个类中创建了 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): error C2065: 'm_LCalc' : undeclared identifier
  • 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”左侧必须有类/结构/联合
    • 类型是“未知类型”





明白了,我是新来的。 @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);
};

【问题讨论】:

  • 定义LCalcultation的头文件是否包含在定义CMFC_App_CalculationDlg的头文件中?
  • 您能否发布 completeunedited 错误消息?并指出您在源代码中的哪些错误。另外,m_LottoBerechnung 是什么?
  • 另外,在m_LottoBerechnung 的声明之前检查你的分号。看来您只是缺少一对。
  • 这是正确的unedited 错误代码...
  • 我没有遗漏任何分号,顺便说一句。它只是说我必须在LCalculation m_LCalc; 之间添加一个。

标签: c++ visual-studio-2010 mfc


【解决方案1】:

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

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

【讨论】:

  • 实际上是第二个标题,但谢谢。我一分钟前就知道了。
  • 是的,我刚刚看到并更正了(现在还给出了 h 文件的名称)。
猜你喜欢
  • 2013-11-02
  • 1970-01-01
  • 2015-04-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多