"Use of undeclared identifier A"
"Use of undeclared identifier A"
你知道是什么导致了这个编译时错误吗?
基本设置:main.cpp
#include <iostream>
#include "GroupTheorizer.h"
int main()
{
// ...
functs::Adder<char> A; // error on this line
/ ...
return 0;
}
GroupTheorizer.h
#ifndef __GroupTheory__GroupTheorizer__
#define __GroupTheory__GroupTheorizer__
class GroupTheorizer
{
// definitions of members of a GroupTheorizer object
// ...
};
#endif /* defined(__GroupTheory__GroupTheorizer__) */
GroupTheorizer.cpp
#include "GroupTheorizer.h"
#include <set>
#include <iostream>
#include <limits>
#include <string>
// ... implementations of GroupTheorizer members
// ...
namespace functs
{
class Adder
{
private:
static const char symbol = '+';
public:
T operator() (const T & x, const T & y) const { return x + y; };
char getSymbol(void) const { return symbol; };
};
// other functors ...
// ...
}
我相当确定我正确地将文件链接在一起,所以可能是什么问题?
看看你的Adder
的实现,似乎你的意思是它是一个模板,但还没有这样写。
你只漏了template <typename T>
行。
template <typename T>
class Adder
{
private:
static const char symbol = '+';
public:
T operator() (const T & x, const T & y) const { return x + y; };
char getSymbol(void) const { return symbol; };
};
相关文章:
- Usages of std::move
- 使用 [] 运算符时"binding reference of type discards qualifiers"
- 如何处理 c++ 中类实现中的"invalid use of non-static data member"?
- 具有变量Number of Arguments的std::函数的矢量
- Capacity of a deque
- Deprecation of _writeBarrier()
- constexpr begin of a std::array
- 如何调整 std::vector of Eigen::MatrixXd 的大小
- C++ "error: invalid use of void expression"
- 我看到"use of undeclared identifier"错误,有人可以告诉我如何解决它吗?
- 赛通"Cannot take address of memoryview slice"
- C++ Version Of Double.longBitsToDouble
- 收到错误"invalid use of non-static data member 'stu::n' "
- "Use of undeclared identifier 'IntQueue' "即使它被定义
- 在 Xcode 中使用 djinni 时"use of undeclared identifier" 'noreturn'
- 如何在Xcode中将长双精度转换为字符串格式?或如何解决错误"use of undeclared identifier 'to_string' "
- 在 iOS 游戏中购买 Cocos2Dx "use of undeclared identifier"
- "Use of undeclared identifier" - 代码有什么问题?
- "Use of undeclared identifier A"
- C++ 语义问题:"'use of undeclared identifier 'balance'"