不能声明fstream对象?但可以将它声明为指针吗?

Jul*_*ulz 1 c++ ifstream

这整个晚上一直在我的头上敲我的头.

我只是试图像这样声明一个ifstream对象....

ifstream inputStream;
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

Error 5 error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: char const & __thiscall std::_String_const_iterator<char,struct std::char_traits<char>,class std::allocator<char> >::operator*(void)const " (??D?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEABDXZ)    C:\Users\Julz\Desktop\My Dropbox\3rdYear\2ndSemester\Games Prog\Game\DemocracyInvaders\Score.obj    DemocracyInvaders
Run Code Online (Sandbox Code Playgroud)

我可以把它声明为像这样的指针......

ifstream *inputStream;
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试读取文件数据时,这只会令人头疼,我想我应该弄清楚为什么在尝试一些被黑客攻击的修复之前基本声明不起作用.

我正在使用SDL并在标题中包含以下几个文件...

#ifndef SDL_GRAPHICS_H //just a class I'm using to initialise my SDL stuff
#define SDL_GRAPHICS_H

#include <stdio.h>
#include <iostream>
#include <vector>
#include <fstream>
#include "SDL.h" 
#include "SDL_ttf.h"
Run Code Online (Sandbox Code Playgroud)

我已经尝试过交换SDL包含C++以上的内容以及各种各样的变化,没有.我的标题包括所有正确的顺序,我想如果包含问题我不能将ifstream声明为指针?

哦,我尝试过使用fstream甚至只是声明ofstream,所有相同的错误.另外,我尝试它的类(源或标题)并不重要,总是一样的.甚至尝试在我的驱动程序(主)文件中声明它直接包含在其中,没有骰子......完全迷失在这里!

Jar*_*Par 7

您似乎无法将C运行时链接到应用程序中.当声明为非指针时,至少会将ifstream类的构造函数引入到您的应用程序中.看起来构造函数调用的函数是C运行库的一部分,因此最终会出现链接错误.