- Formatting for casts - 2 Updates
- Getters & Setters argument - 2 Updates
- cmsg cancel <mcvsnm$kg8$3@dont-email.me> - 1 Update
Paul N <gw7rib@aol.com>: Mar 04 02:48PM -0800 I've decided to try to use the C++-style casts. But they look ugly! The best I have managed so far is to add spaces to give: ti.lpszText = const_cast <LPTSTR> (text); But this is still ugly, and is difficult to read - the round brackets look like an optional extra instead of being an essential part of the cast. Does anyone have anything better? Or is it the case, as one tutorial seemed to hint, that the casts are deliberately ugly to dissuade people from writing code that uses them? Thanks. Paul. |
Christopher Pisz <nospam@notanaddress.com>: Mar 04 05:02PM -0600 On 3/4/2015 4:48 PM, Paul N wrote: > But this is still ugly, and is difficult to read - the round brackets look like an optional extra instead of being an essential part of the cast. Does anyone have anything better? Or is it the case, as one tutorial seemed to hint, that the casts are deliberately ugly to dissuade people from writing code that uses them? > Thanks. > Paul. How is it ugly? Would it be better with blonde hair? const_cast<wchar_t *>(text); Looks pretty to me and I haven't even drank that many beers today. I guess because I am used to templates. I don't think I'd be casting to LPTSTR though. What's the type of text? std::string::c_str() might be just fine. -- I have chosen to troll filter/ignore all subthreads containing the words: "Rick C. Hodgins", "Flibble", and "Islam" So, I won't be able to see or respond to any such messages --- |
JiiPee <no@notvalid.com>: Mar 04 09:25PM On 04/03/2015 20:21, Öö Tiib wrote: > for him. That does not pass any reviews and so he should go back > practicing to output ASCII texts ... "Hello World!" and from there > perhaps Visual Basic, PHP ... no way C++. ;) hmmm, are you mocking PHP?? :) They would not like it... |
Paul N <gw7rib@aol.com>: Mar 04 02:42PM -0800 On Wednesday, 4 March 2015 13:46:50 UTC, JiiPee wrote: > and create Get and Set functions to get and set their values... Thats > what they teach in schools > and all the books seems to say that as well. You did not know that?? The point (no pun intended) here is that it doesn't matter if you change the value of one of the coordinates. You just get a different point. Getters and setters are for when a class needs to manage its own data, without other people messing about with it. Or, as Flibble pointed out, where there is a "class invariant". > } > Should age be inside a class and should we have a Get to get access to > it, just like we did with coordinate? Like this: Actually, I think there is a good case for a "person" class to have age as a getter. For one thing, as others have said, a person does not change their date of birth and so there is no reason for that to be externally alterable. But, as I don't think anyone else has said - the fact that someone had a particular age at some point in the past is no guarantee that they have that age now. So you ought to be calculating the age, based on the current date, instead of just looking up something stored earlier. |
bleachbot <bleachbot@httrack.com>: Mar 01 09:28PM +0100 |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment