| RockDog (3) | |||||
|
Hello Fellas I was working with a C++ programming book and I've been working through the chapters and i came across an assignment i decided to tackle. For some reason i keep having problems, I had been working on this assignment for a while and the reason i chose this assignment is because i've seen a lot of posts online talking about this assignment and I was wondering if you guys could explain to me what i am doing wrong. Thanks in advance. Here is the Implementation File and what i'm trying to accomplish is this: creating a class that is dayType and be able to print the day, set the day, return the next and previous days and have constructors to be able to do so and then test it with the main method to show everything as usual.
This is my main Method, every time i try to test the class with the main method i always get garbage some huge negative number which is probably just memory trash i'm assuming.
i've been experimenting with this forever and for some reason i can't get it to work right any help would be appreciated. Thanks. | |||||
|
|
|||||
| guestgulkan (2916) | |||
Let's start here:
| |||
|
Last edited on
|
|||
| RockDog (3) | |
|
the setd=day is referring to the day private variable in the class will that not work the way it is? that is probably the problem i guess? | |
|
Last edited on
|
|
| guestgulkan (2916) | |
|
With the assignment operator, the object you want to change goes on the left of the = sign; object_to_be_changed = new_value See if you can figure out what you have done wrong now. | |
|
|
|
| RockDog (3) | |
| Ha! very stupid mistake on my part. I should have known that! Thank you very much Guestgulkan for pointing that out for me i been banging my head for a while now cause i knew the rest was right but i was so puzzled why that wasn't working. I really appreciate your help :) | |
|
|
|
| MrProxx (5) | |
|
Also, nothing to do with your question or anything.. but isn't switch case a better idea instead of if(day ==1)... if(day == 2)... switch(day){ case 1: //Do something; break; case 2: //Do something; break; ... } just to give you an idea.. | |
|
|
|