小编Pho*_*ton的帖子

不能在c ++中使用构造函数初始化对象

   #include <iostream>
using namespace std;

class Book
{
public:
Book(const string& ISBN,const string& title,const string& author,const string& cprDate,const bool& ch);
void checkBook(void);
void uncheckBook(void);
string ISBN(){return I;};
string title(){return t;};
string author(){return a;};
string cprDate(){return c;};
bool isChecked(){return check;};
private:
string I;   //ISBN
string t;   //title
string a;   //author
string c;   //copyright date
bool check; //is checked?
};

Book::Book(const string& ISBN,const string& title,const string& author,const string& cprDate,const bool& ch){
I=ISBN;
t=title;
a=author;
c=cprDate;
check=ch;
}

void Book::checkBook(void)
{
check=true;
} …
Run Code Online (Sandbox Code Playgroud)

c++ constructor object codeblocks

-1
推荐指数
1
解决办法
359
查看次数

标签 统计

c++ ×1

codeblocks ×1

constructor ×1

object ×1