我在C++代码中遇到了一个有线问题。我使用TCLAP软件接受命令行参数,其中一个标志是一个文件名:在const char *中传入一个方法,但得到char const *错误
TCLAP::ValueArg<string> Poly ("p", "poly", "file name of the polynomial", false, "", "string");
我也有一个接受3个参数的另一个功能,
void GetBiPoly(const char *filename, BiPoly<BigFloat> *u, BiPoly<BigFloat> *v);
我传递保利字符串函数GetBiPoly
这样:
benchmark::GetBiPoly(Poly.getValue().c_str(), &fxy, &gxy);
当我编译程序,它给了我下面的错误:
miranda.cpp:(.text+0x1900): undefined reference to `benchmark::GetBiPoly(char const*, CORE::BiPoly<CORE::BigFloat>*, CORE::BiPoly<CORE::BigFloat>*)'
看来唯一的区别是错误信息中文件名的类型是char const*
,而定义是const char*
。任何人都可以告诉我这是什么问题吗?谢谢。
这两种形式是等价的。你的问题是你没有链接到实现,或者它在另一个命名空间。 – pyroscope