Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么我的类对象会导致未声明的标识符错误? 我正在编写一个微软Visual C++ 2010 Express程序,AM与我的类对象有一个问题。我不断得到未声明的标识符和丢失的“;”在标识符错误之前,我不确定是什么导致了问题_C++ - Fatal编程技术网

为什么我的类对象会导致未声明的标识符错误? 我正在编写一个微软Visual C++ 2010 Express程序,AM与我的类对象有一个问题。我不断得到未声明的标识符和丢失的“;”在标识符错误之前,我不确定是什么导致了问题

为什么我的类对象会导致未声明的标识符错误? 我正在编写一个微软Visual C++ 2010 Express程序,AM与我的类对象有一个问题。我不断得到未声明的标识符和丢失的“;”在标识符错误之前,我不确定是什么导致了问题,c++,C++,我已经检查了我的标题是否有任何错误,并做了一些更改,看看它是否能在没有运气的情况下解决问题 // RightJust class declaration that right justifies the numbers. #ifdef RIGHTJUST_H_ #define RIGHTJUST_H_ #include "stdafx.h" #include <iostream> #include <string> #include <cstring> usi

我已经检查了我的标题是否有任何错误,并做了一些更改,看看它是否能在没有运气的情况下解决问题

// RightJust class declaration that right justifies the numbers.
#ifdef RIGHTJUST_H_
#define RIGHTJUST_H_
#include "stdafx.h"
#include <iostream>
#include <string>
#include <cstring>
using namespace System;
using namespace std;
class RightJust
{
    private:
        int x, totalWH1, totalWH2, totalWH3, totalWH4;  
        int itemT1, itemT2, itemT3, itemT4, itemT5;     // Holds item totals
        string WH1, WH2, WH3, WH4;
        int num[4][5];          // Array containing data
    public:
        RightJust();
        int warehouseLen();
        void rightJustZero();
        void rightJustLess();

};

你头上的防护罩是错误的。应该是

#ifndef RIGHTJUST_H_
如果未定义符号,则使用
#ifdef righjust_H 
将跳过代码


您不应该在.h文件中包含“stdafx.h”。而且,由于您似乎正在使用Visual Studio,您可以只使用一次
#pragma
而不是include guard。

标题中缺少一个
#endif
。我不确定这些代码是否足以找到问题的解决方案。如果它复制了您的错误消息就足够了。不要将
#包含“stdafx.h”
在标题中。欢迎使用。阅读它可能会有所帮助,MCVE解释了您是如何知道这一点的:我不确定这些代码是否足以找到问题的解决方案。我已经做了更改,但现在我在构造函数中初始化的二维数组出现错误
num[4][5]={14,15,5,0,16,15,20,25,0,5,25,40,30,20,5,3,10,0,10}
错误C2059:语法错误:'{'
@ymneedhelp您应该问一个不同的问题。这与此完全无关。编辑此内容应有助于:
Test3.cpp
1>Test3.cpp(24): error C2065: 'RightJust' : undeclared identifier
1>Test3.cpp(24): error C2146: syntax error : missing ';' before identifier 'type'
1>Test3.cpp(24): error C2065: 'type' : undeclared identifier
1>Test3.cpp(27): error C2065: 'type' : undeclared identifier
1>Test3.cpp(27): error C2228: left of '.rightJustZero' must have class/struct/union
1>          type is ''unknown-type''
1>Test3.cpp(31): error C2065: 'type' : undeclared identifier
1>Test3.cpp(31): error C2228: left of '.rightJustLess' must have class/struct/union
1>          type is ''unknown-type''
#ifndef RIGHTJUST_H_