Home > Back-end >  Why can't do excuse me such initializes the members of the class
Why can't do excuse me such initializes the members of the class

Time:11-07

#include
using namespace std;

The class Stock
{
Private:
String _company.
Long _share;
Double _val.
};
Int main ()
{Stock food=Stock (" hello ", 12,20.5);
return 0; }

CodePudding user response:

The default constructor is no parameters, you have to write a constructor with three parameters

CodePudding user response:

reference 1st floor SuperDay response:
, the default constructor is no parameters do you want to write a constructor with three parameters

Write a should be in the class

CodePudding user response:

Haven't written a constructor? Reading a book to learn to write

CodePudding user response:

The class Stock
{
Private:
String _company.
Long _share;
Double _val.
Public:
Stock (string company, long share, double val);
};
Stock: Stock (string company, long share, double val)
{
_company=company;
_share=share;
_val=val;
}
  • Related