相关疑难解决方法(0)

函数默认参数和标题

我是C++的新手.我在设置标题时遇到问题.这是来自functions.h

extern void apply_surface(int, int, SDL_Surface *, SDL_Surface *,SDL_Rect *);
Run Code Online (Sandbox Code Playgroud)

这是functions.cpp的函数定义

void
apply_surface(int x, int y, SDL_Surface * source, SDL_Surface *
destination,SDL_Rect *clip = NULL)
{
    ...
}
Run Code Online (Sandbox Code Playgroud)

这就是我在main.cpp中使用它的方式

#include "functions.h"
int
main (int argc, char * argv[])
{
    apply_surface(bla,bla,bla,bla); // 4 arguments, since last one is optional.
}
Run Code Online (Sandbox Code Playgroud)

但是,这不会编译,因为,main.cpp不知道last参数是可选的.我怎样才能做到这一点?

c++ header

48
推荐指数
2
解决办法
4万
查看次数

标签 统计

c++ ×1

header ×1