C++ 没有用于“Phone”(CPP)初始化的匹配构造函数

C++ 没有用于“Phone”(CPP)初始化的匹配构造函数,c++,constructor,int,C++,Constructor,Int,编辑:已解决。我是个白痴。我把数字改成64 初学者程序员这里有一个与构造函数有关的C++问题。当我通过Xcode编译时,我得到以下错误: 没有用于初始化“Phone”的匹配构造函数 我通过本教程自学: 下面列出的代码,但我也有一个屏幕截图,如果它使它更容易阅读 谢谢 #include <iostream> // Creating a Class for the type of phone. class Phone { public: std::string manufacture

编辑:已解决。我是个白痴。我把数字改成64

<>初学者程序员这里有一个与构造函数有关的C++问题。当我通过Xcode编译时,我得到以下错误:

没有用于初始化“Phone”的匹配构造函数

我通过本教程自学:

下面列出的代码,但我也有一个屏幕截图,如果它使它更容易阅读

谢谢

#include <iostream>

// Creating a Class for the type of phone.
class Phone {
public:
std::string manufacturer;
std::string model;
int capacity; //in GB

// Creating a Constructor. This will be called whenever we create a "Phone" object.
Phone(std::string aManufacturer, std::string aModel, int aCapacity) 
  {
    manufacturer = aManufacturer;
    model = aModel;
    capacity = aCapacity;
  }
};

int main()
{
// Objects
Phone iPhone("Apple", "6s", "64"); // This is where the error occurs
}

您已将容量定义为整数

你需要写:

int main()
{
    Phone iPhone("Apple", "6s", 64);
}

那就是。。。64,不带引号。

手机需要一个int作为acacacacity,但你通过了64。试试iPhoneApple手机,6s,64;是的,这个修好了。现在我觉得自己像个白痴。谢谢@songyuanyao!