【问题标题】:Undeclared Identifier with all the right includes具有所有权利的未声明标识符包括
【发布时间】:2014-11-19 12:39:36
【问题描述】:

每次我尝试构建程序时都会收到此错误:

error C2065: 'DepositoFresco' : undeclared identifier

我创建的DepositoFrescoDepositoNormalDeposito 的每个实例都会发生这种情况。 DepositoNormalDepositoFrescoDeposito(虚拟类)的子类。我拥有所有权利,所以我不知道是什么原因造成的。 错误发生在“Armazem”类中,我在其中实例化了其中的几个以插入向量等。代码如下:

Armazem::Armazem(int nF, int nN, int nPF, int nPN, int distMaxi, int distMini) : depositos(), distancia(), graphStlPath <Deposito*, int>() {
distMax = distMaxi;
distMin = distMini;

for (int i = 0; i < nF; i++) {
    DepositoFresco* df = new DepositoFresco(random(1, 20), (float)random(1000, 10000), nPF);
    depositos[i] = df;
}

for (int j = nF; j < nF + nN; j++) {
    DepositoNormal* dn = new DepositoNormal(random(1, 20), (float)random(1000, 10000), nPN);
    depositos[j] = dn;
}

preencherMatriz();
}

另外,Armazem 是另一个名为 GraphStlPath 的模板类的子类,但我认为问题不在这里。

编辑:这里包括:include "Deposito.h" include "DepositoFresco.h" include "DepositoNormal.h" include "graphStlPath.h" include <vector> include <map> include <stdlib.h> include <stdio.h> include <time.h> include <typeinfo> include <iostream> include <fstream> include <string>

非常感谢您找到问题的任何帮助。

【问题讨论】:

标签: c++ undeclared-identifier


【解决方案1】:

我的心理调试能力告诉我,您的包含中有一个循环,并且标头保护或#pragma once 正在启动,使编译器的代码消失。

那个,或者你不尊重命名空间。但第一个可能性更大。

【讨论】:

  • 问题不在这个类中,我在这个类包含的一个类中包含这个类(出于某种原因),生成一个循环。如果其他人看到这一点并且不明白究竟是为什么,只是回答一下。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-30
  • 1970-01-01
相关资源
最近更新 更多