我有一个未解决的外部符号错误,这让我疯狂.简而言之,我有一个SDL_Surfaces包装类('DgSurface')和一个加载和存储DgSurfaces('DgSurfaceList')的类.尝试在我的项目中包含DgSurfaceList文件时出现链接问题.这是我的课程:
头文件"DgSurface.h"包含DgSurface类声明:
#ifndef DGSURFACE_H
#define DGSURFACE_H
#include "SDL.h"
#include <string>
class DgSurface
{
public:
//Constructor/destructor
DgSurface(std::string N, SDL_Surface* I): image(I), name(N) {}
DgSurface() {name = ""; image = NULL;}
~DgSurface();
//Copy operations
DgSurface(const DgSurface&);
DgSurface& operator= (const DgSurface&);
//Data members
std::string name; //The name of the image
SDL_Surface* image; //The image
};
#endif
Run Code Online (Sandbox Code Playgroud)
cpp文件"DgSurface.cpp"包含DgSurface定义:
#include "DgSurface.h"
#include "SDL.h"
//--------------------------------------------------------------------------------
// Constructor
//--------------------------------------------------------------------------------
DgSurface::DgSurface(const DgSurface& other)
{
//Copy name
name = other.name;
//Create new SDL_Surface
image = SDL_ConvertSurface(other.image, other.image->format, 0);
} …Run Code Online (Sandbox Code Playgroud) 我可以按如下方式验证函数签名:
template <typename>
struct FnType
{
static bool const valid = false;
};
struct FnType<void(int)>
{
static bool const valid = true;
};
void foo(int)
{
}
FnType<decltype(foo)>::valid; //true
Run Code Online (Sandbox Code Playgroud)
如何验证类方法签名?
class Y
{
public:
void foo(int)
{
}
};
FnType<decltype(&Y::foo)>::valid; //false??
Run Code Online (Sandbox Code Playgroud)
我想验证Y::foo返回类型和参数类型是否有效。