How to make the code working?
Is it possible to write the constructor of below code snippet?
How to write the definition of Book class constructor?
#include <iostream>
#include <cstring>
using namespace std;
struct Document {
void PrintNameOf();
private:
char *name;//?
};
void Document::PrintNameOf() {
cout << name << endl;
}
struct Book : public Document {
public:
Book(const char *name, const long pagecount );
private:
long pagecount;
};
//book constructor
int main()
{
constexpr auto title1{"the summary of all movies"};
constexpr auto pageCount1{1050};
constexpr auto title2{"c++ is the real deal"};
constexpr auto pageCount2{890};
Book b1{title1, pageCount1};
Book b2{title2, pageCount2};
b1.PrintNameOf();
b2.PrintNameOf();
return 0;
}
Is it possible to write the constructor of above program?
Aucun commentaire:
Enregistrer un commentaire