rushlooki.blogg.se

Setdate
Setdate













setdate

Setdate code#

Your code compiles, but it wouldn't have the right effect, had you actually called the function. So in your case nothing happens, apart form year being returned. Side effects usually happen when there is assignment in one of the expressions. The comma operator is used in other situations where the side effects of the expressions (other than the last one) are relied upon. With the comma operator only the right hand expression is considered. What actually happens when the compiler encounters return month, day, year is the comma operator comes into effect. The problem is that one can only return 1 value form a function. I am still confused on what the actual problem is. I gather you can see that d2 is ? The code works fine (except I would have the private function like I mentioned) Important to realise here that just because code works, it doesn't mean it is right :+)įor the getDate line, I was trying to follow the teachers notes but when I removed it, the code compiled anyway with the same results. #include #include #include "Date.h" using namespace std Ĭout << month << "/" << day << "/" << year Ĭout << Month << " " << day << ", " << year Ĭout << day << " " << Month << " " << year I have watched alternative videos and read the other posts in this forum but I couldn't find one that helped with this problem. I don't know why my d1.setDate(8, 29, 1986) is not being set.

setdate

Modified the code so I can see the results I can not get my code to return the (8, 29, 1986) in the format required by the question. ShowDate3() should display the date in 1 January 2001 formatĪlso the class should have method to set the date(setDate()).This method should take month, day, and year as parameters and set the object instance data member values. ShowDate2() should display the date in January 1,2001 format ShowDate1() should display the date in format The class should have following three member functions to display date following formats Default constructor that does not take any parameters should set the default values of 1(month),1(day),2001(year). The class should have a three-parameter constructor that allows the data to be set at the time of new Data object instances are created. See also textFromDateTime() and validate(). This virtual function is used by the datetime edit whenever it needs to interpret text entered by the user as a value. Returns an appropriate datetime for the given text. Design and Implement a class called Date that has data members to store month (as a number), day, year, and name of the month. virtual protected QDateTime QDateTimeEdit:: dateTimeFromText (const QString &text) const.















Setdate