How can I use a constructor as a parameter to another constructor in c++?
I created two classes, Book & Date. The Date constructor simply takes 3 int arguments for day, month and year. The Book constructor takes string isbn, string title, string author, Date copyright_date. I thought I could use the Date constructor to create a Date object inside the Book constructor but it doesn't seem to be working. #include <bits/stdc++.h> using namespace std; class Date{ public: class Invalid{};//to throw in error Date(int d,int m,int y); Date() = default; //getters int get_day(){return day;}; int get_month(){return month;}; int get_year(){return year;}; //helper functions priva
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.