構造函數(shù)中的這個color:"黑";的作用是什么???(各位大神幫忙看一下)
#include<iostream>
using namespace std;
class Car
{
?? ?public:
?? ??? ?Car();
?? ??? ?Car(string c);
?? ??? ?void run();
?? ?private:
?? ??? ?string color;?? ??? ?
};
Car::Car()
{
?? ?color:"黑";
?? ?cout<<""<<endl;
}
Car::Car(string c)
{
?? ?color=c;
?? ?cout<<color<<endl;
}
void? Car::run()
{
?? ?cout<<color<<endl;
}
int main()
{
?? ?Car c1("紅");
?? ?Car c2("黑");
?? ?Car c3;
?? ?c1.run();
?? ?c2.run();
?? ?c3.run();
?? ?return 0;?? ?
}
2016-12-09
我不知道啊。。。。