on-internet
← Community

How can i use a contructor as parameter to another constructor in c++

Stack Overflow ·

An exercise am working on, 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 doesnt 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;}

Comments

Sign in or sign up to comment and upvote.

No comments yet.