什么会阻止我创建类的非指针变量
What would stop me from creating a non pointer variable of my class?
编辑::这似乎是Visual Studio 2013的一个bug。
由于某些超出我理解的原因,我不能创建类的非指针变量LineBuffer。我的代码中有许多类使用相同的格式,但它们都可以工作。我尝试更改名称,因为我认为可能类名称在其他地方被使用,但它仍然失败。我是不是错过了什么简单的东西?是否有打字错误,我无法找到在过去的2小时试图解决这个问题?这简直让我头疼。任何帮助这里将非常感激!
class TestClass
{
LineBuffer lineBuffer;
void LoadLine()
{
lineBuffer = LineBuffer();
}
};
我得到的错误如下:
错误3错误LNK1120: 2个未解决的外部E: soreooth DevelopmentTestProjectsGraphicsDev-TestDebugGraphicsDev-Test.exe 11 GraphicsDev-Test
错误2错误LNK2019:未解析的外部符号"__declspec(dllimport) public: __thiscall LineBuffer::~LineBuffer(void)"(__imp_??1LineBuffer@@QAE@XZ)在函数__unwindfunclet$??0 testclass@@qae@xz 10美元E: SoreTooth 开发 TestProjects GraphicsDev-Test GraphicsDev-Test 主要。obj GraphicsDev-Test
错误1错误LNK2019:未解析的外部符号"__declspec(dllimport) public: __thiscall LineBuffer::LineBuffer(void)"(__imp_??0LineBuffer@@QAE@XZ)在函数"public: __thiscall TestClass::TestClass(void)"中引用(? ? 0 testclass@@qae@xz) E: SoreTooth 开发 TestProjects GraphicsDev-Test GraphicsDev-Test 主要。obj GraphicsDev-Test
LineBuffer.h类的代码:#ifndef _LineBuffer_
#define _LineBuffer_
#include "GraphicsManagement_API.h"
class GraphicsManagement_API LineBuffer
{
public:
LineBuffer();
~LineBuffer();
};
#endif
LineBuffer.cpp的代码:
#include "LineBuffer.h"
LineBuffer::LineBuffer()
{
}
LineBuffer::~LineBuffer()
{
}
我知道你会问,GraphicsManagement_API.h的代码:
#ifndef _GraphicsManagement_API_
#define _GraphicsManagement_API_
#include <d3d10.h>
#include <D3DX10.h>
#ifdef _GraphicsManagement_API_EXPORTS_
#define GraphicsManagement_API __declspec(dllexport)
#else
#define GraphicsManagement_API __declspec(dllimport)
#endif
#endif
但这恰好可以
class TestClass
{
LineBuffer * lineBuffer;
void LoadLine()
{
lineBuffer = new LineBuffer();
}
};
如果您碰巧遇到这个问题,通过删除它们然后创建一个全新的文件来重新创建有问题的文件。在我的例子中,当我创建LineBuffer.cpp时,我意外地将其命名为LineBuffer。ccp显然这不会生成,并且Visual Studio不会将其识别为。cpp文件。我想我可以使用Visual Studio解决方案资源管理器重命名文件。显然,这并不像人们预期的那样起作用。我不得不删除整个文件并创建一个新文件。一旦我这样做了,它就成功构建了。我不确定这是Visual Studio 2013的bug还是设计。不管怎样,这都是适合我的解决方案。
- 指针变量在 cout 函数中不起作用
- 如何将指针变量作为引用参数传递?
- 有没有办法在同名类 (c++) 中为对象分配一个指针变量
- 我试图了解在异或操作后指针变量正在更改
- 调用带有指针对象错误的指针变量
- 如何在 cuda 中将结构的指针变量从主机复制到设备
- 非指针变量和类成员上的新放置
- 线路抑制状态错误 C4703 可能未初始化的局部指针变量"back"已使用
- 全局外部指针变量在 DLL 中不可见
- 如何访问在 c++ 中在类内声明的结构类型指针变量?
- C++ 中指针变量的内存释放
- 使用指针变量打印特定的数组变量
- 如何使用构造函数初始化内存地址(指针变量)?
- 如何释放为指针变量本身提供的内存?
- 如果地址已知,如何获取指针变量的名称
- 如何处理参数中的基类和指针变量
- 指针变量 在数组中定位零
- 隐式指针变量,在自动定义中具有另一个指针变量
- 为什么可以将Char指针变量初始化为字符串,而INT指针变量不能初始化到整数数组
- 错误 C4703 可能未初始化的局部指针变量'y'使用