English 中文(简体)
列入“h”案时的链接错误,但在列入记者档案时消失。
原标题:Linker error when including an .h file but disappears when including the correspondent .cpp file

这是奇怪的。 当我把一 file(Search.h)列入档案时,我怎么会遇到错误,但是,当我列入文件(Search.cpp)时,似乎一切都只是罚款?

www.un.org/spanish/ga/president

#ifndef GENERALSEARCH_H_
#define GENERALSEARCH_H_

#include "Problem.h"
#include "Node.h"

template <class T>
class GeneralSearch
{
public:

    const Node* treeSearch(const Problem &problem) const;
    const Node* graphSearch(const Problem &problem, T &fringe = T()) const;

private:
    void expand(const Node &node, const Problem &problem, list<const Node*> &out) const;
};

#endif

http://www.ohchr.org。

#include "GeneralSearch.h"
template <class T>
void GeneralSearch<T>::expand(const Node &node, const Problem &problem, list<const Node*> &out) const
{
...
}

template <typename T>
const Node* GeneralSearch<T>::treeSearch(const Problem &problem) const
{
...
}

template <typename T>
const Node* GeneralSearch<T>::graphSearch(const Problem &problem, T &fringe = T()) const
{
...
}

Program file -workingING

#include "GeneralSearch.cpp"
#include "DummyProblem.h"
#include "DepthFirstSearch.h"
#include <queue>

int main (int argc, char* argv[]){}

Program file - NOTworkingING

#include "GeneralSearch.h"
#include "DummyProblem.h"
#include "DepthFirstSearch.h"
#include <queue>

int main (int argc, char* argv[]){}
问题回答

联系人试图在联系时找到未解决姓名的定义。 在第二种情况下,联系人无法找到普通类成员职能的定义,因此,你有错误。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签