提问人:ModernEraCaveman 提问时间:6/2/2023 最后编辑:273KModernEraCaveman 更新时间:6/2/2023 访问量:69
如何在调用具有指定确切参数的对象构造函数时修复参数列表错误?
How can I fix an argument list error while calling an objects constructor with the exact arguments specified?
问:
我正在尝试在对象构造函数中设置一个多类型名方法以从派生类中调用,但我无法弄清楚为什么会出现以下错误:
no instance of constructor "VBO::VBO" matches the argument list
argument types are:
(VkGraphicsPipeline *, std::vector<Vertex, std::allocator<Vertex>>)
VBO 对象定义如下:
struct VBO {
VkBuffer buffer;
VkDeviceMemory memory;
VBO(VkGraphicsUnit* pVkGPU, std::vector<std::variant<Vertex, uint32_t>> content) {
...; }
};
VkGraphicsPipeline 对象定义为 VkGraphicsUnit 对象的子对象:
struct VkGraphicsPipeline : VkGraphicsUnit {
VkGraphicsPipeline(VulkanAPI VkApplication, std::vector<Vertex> vertices) : VkGraphicsUnit(VkApplication) {
VBO(this, vertices);
...; }
};
我尝试了以下方法,但都未能修复错误:
在“VkGraphicsUnit”之前添加“public”
struct VkGraphicsPipeline : public VkGraphicsUnit
将 VBO 添加为 VkGraphicsPipeline 的子类
删除 VkGraphicsUnit 的继承并显式调用它
struct VkGraphicsPipeline {
VkGraphicsPipeline(VkGraphicsUnit* pVkGPU, std::vector<Vertex> vertices) {
VBO(pVkGPU, vertices);
...; }
};
甚至在 VBO 构造函数中尝试其他可用的变体
VkGraphicsPipeline(VkGraphicsUnit* pVkGPU, std::vector<uint32_t> indices) {
VBO(pVkGPU, indices); }
在最后两种情况下,我得到的错误是,
no instance of constructor "VBO::VBO" matches the argument list
argument types are:
(VkGraphicsUnit *, std::vector<Vertex, std::allocator<Vertex>>)
和
no instance of constructor "VBO::VBO" matches the argument list
argument types are:
(VkGraphicsUnit *, std::vector<uint32_t, std::allocator<uint32_t>>)
我完全迷失了解决方案。请帮助我找出我缺少什么,以及如何/是否可以在不使我的代码比现在更复杂的情况下解决此错误。
答: 暂无答案
评论
VBO(this, vertices);
应该在成员初始值设定项列表中吗?在构造函数的主体中,它没有任何用处