未解析的外部符号"class"
Unresolved External symbol "class"
错误LNK2001未解析的外部符号"类对象"
当这个类被声明为extern时,它会为连接到它的每一段代码创建这个链接器错误。但当我在其他文件中创建这个类的私有版本时,它们可以正常工作。
更改类变量的名称没有任何效果,因此它不会与导致错误的映射系统发生冲突。
我无法查看和修改错误。它以前是工作的,我打开了文件,希望它能再次运行,但它没有。
对象.cpp
#include "object.h"
#include "Ball.h"
// Constructor
Object::Object() {
std::map<int, std::map<int, IMAGEINFO>> object;
};
Object::~Object() {
object.clear();
};
void Object::Update() {
// Gets all the base object ID's
for (unsigned int i = 0; i < object.size(); i++) {
// Gets all the object's inside that ID.
for (unsigned int j = 0; j < object[i].size(); j++) {
// Gets the object.
IMAGEINFO obj = object[i][j];
// Calls for the processes of the object
obj.Update();
}
}
}
void Object::Render(HDC hdc, RECT* prc, BITMAP bm) {
// Gets all the base object ID's
for (unsigned int i = 0; i < object.size(); i++) {
// Gets all the object's ID's.
for (unsigned int j = 0; j < object[i].size(); j++) {
// Gets the object.
IMAGEINFO obj = object[i][j];
// Calls for the rendering of the object
obj.Render(hdc, prc, bm);
}
}
}
int Object::addObject(IMAGEINFO obj) {
bool index = false;
int indexVal;
short run = 0;
while (!index) {
if (typeid(obj).name() == typeid(object[run]).name()) {
object[run][object[run].size()] = obj;
indexVal = object[run].size();
index = true;
}
else if (run == object.size()) {
object[run][0] = obj;
indexVal = 0;
index = true;
}
run++;
}
return indexVal;
}
object.h
#ifndef OBJECT_H
#define OBJECT_H
#endif
#include <windows.h>
#include <iostream>
#include <map>
#include "renderer.h"
#include "resource.h"
class Object {
public:
// Constructors/Deconstructors
Object();
~Object();
// Processes
int addObject(IMAGEINFO value);
void Update();
void Render(HDC hdc, RECT* prc, BITMAP bm);
private:
std::map<int, std::map<int, IMAGEINFO>> object;
};
extern Object objects;
Ball.cpp
#include "Ball.h";
int indexPos;
HBITMAP hbm_Ball_Image = NULL;
HBITMAP hbm_Ball_Mask = NULL;
IMAGEINFO ballInfo;
void Ball(BITMAP bm, int assx, int assy) {
indexPos = objects.addObject(ballInfo);
hbm_Ball_Image = createImage((HBITMAP) BITMAP_BALL);
hbm_Ball_Mask = createMask((HBITMAP)BITMAP_BALL, RGB(255, 255, 255), bm);
GetObject(hbm_Ball_Image, sizeof(bm), &bm);
ballInfo.height = bm.bmHeight;
ballInfo.width = bm.bmWidth;
ballInfo.x = assx;
ballInfo.y = assy;
ballInfo.speedX = 1;
ballInfo.speedY = 0;
}
球.h
#ifndef BALL_H
#define BALL_H
#endif
#include <windows.h>
#include <iostream>
#include <map>
#include "renderer.h"
#include "resource.h"
#include "object.h"
void Ball(BITMAP bm, int assx, int assy);
void render(HDC hdc, RECT* prc, BITMAP bm);
添加
Object objects; // construct an instance of the class
到文件Object.cpp 的末尾
相关文章:
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 有符号的int和int-有没有一种方法可以在C++中区分它们
- 将无符号char*转换为std::istream*C++
- 如何在C++中将一个无符号的 int 转换为两个无符号的短裤?
- vscode g++链路故障:体系结构x86_64的未定义符号
- 从矢量<无符号字符>转换为字符* 包括垃圾数据
- 如何理解将半精度指针转换为无符号长指针和相关的内存对齐
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 使用gcc从静态链接的文件中查找可选符号
- C++中无符号字符溢出
- 错误 LNK2001:未解析的外部符号"private: static class Game Game::game_"
- 共享库中非模板基的模板子类导致未定义的符号类型信息'class'链接错误
- 错误 LNK2001:未解析的外部符号"__declspec(dllimport) public: class QString & __thiscall QString::operator=(clas
- 错误 LNK2001:未解析的外部符号"class ATL::CTraceCategory ATL::atlTraceException" (?atlTraceException@ATL@@3VCTr
- 错误 LNK2001:未解析的外部符号"public: static class sf::RenderStates const sf::RenderStates::Default"
- 未解析的外部符号"public: class Foo __thiscall Bar::bu(char const *)"
- 未解析的外部符号"class"
- Player.obj :错误LNK2001:未解析的外部符号"private: static class InputHandler * InputHandler::s_pInstance"
- 错误:'class name'重新声明为不同类型的符号?