![]() ![]() Because you never called the function, it doesn't make any difference to anything. 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. Design a class called Date that: The class has integer data members to store month, day, and year. 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. The class should have a three-parameter default constructor that allows the date to be set at the time a new Date object is created. Use Index.toframe and then DataFrame. Using resetindex directly on the read data frame may not be convenient because the rest of the columns no longer have the Date index. const date new Date() // Its hard to tell from the function name what is. As you can see Date belongs to the index and therefore you cannot select it by its label. Modified the code so I can see the results Design a class called Date that has integer data members to store month, day, and year. If your class/object name tells you something, dont repeat that in your. 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. Design and Implement a class called Date that has data members to store month (as a number), day, year, and name of the month. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |