- polymorph? - 6 Updates
- what is the return type of std::bind()? - 2 Updates
- OT: World War III - 10 Updates
- This is causing some of my C++ students a major headache ... - 3 Updates
- polymorph? - 3 Updates
- Xn invites implements, review, or simply any idea. - 1 Update
Jerry Stuckle <jstucklex@attglobal.net>: Mar 22 07:38PM -0400 On 3/22/2016 7:12 PM, Öö Tiib wrote: > lot more often than composition. We can not solve a OOP question if > square is kind of rectangle or not by uttering such religious slogans > and suggesting that rectangle is component of square. ;) Yes, a square is a more specific instance of a rectangle, just like a rectangle is a more specific instance of a parallelogram. And that is a more specific instance of a quadrilateral. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ================== |
woodbrian77@gmail.com: Mar 22 06:51PM -0700 On Tuesday, March 22, 2016 at 6:13:07 PM UTC-5, Öö Tiib wrote: > That "composition over inheritance" is IMHO a mantra. It has a kernel > of good truth in it but that is turned into religious slogan. Religious > slogans are considered harmful. The national motto of the United States is "In G-d we trust." Brian Ebenezer Enterprises http://webEbenezer.net |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 23 05:24AM +0100 > The national motto of the United States is "In G-d we trust." The adoption of it as a national motto happened at the same time as segregation was abolished. Which would place it around 1956, if memory serves me right. Anyway you can google it. I think it was a fair exchange at the time: adopt a lunatic national motto, a motto which after all had appeared on flags and coins earlier, but get rid of segregation − or at least a good start on that. However, now with a black US President the time may have come to finally get rid also of the since 1956 state-endorsed lunacy. The Founding Fathers did not want that: they would have been shocked to know it was adopted. Unfortunately it's been reaffirmed by voting many times in recent years, and most Americans are in favor of it. :( Cheers & hth., - Alf |
scott@slp53.sl.home (Scott Lurndal): Mar 23 01:35PM >The national motto of the United states is "Out of many, one" (act of congress, 1782). |
"Öö Tiib" <ootiib@hot.ee>: Mar 23 01:08PM -0700 > > of good truth in it but that is turned into religious slogan. Religious > > slogans are considered harmful. > The national motto of the United States is "In G-d we trust." I meant "religious" in sense of "dogmatic" or "superstitious". Sort of like "build a wall". |
woodbrian77@gmail.com: Mar 23 02:36PM -0700 On Wednesday, March 23, 2016 at 3:09:14 PM UTC-5, Öö Tiib wrote: > > The national motto of the United States is "In G-d we trust." > I meant "religious" in sense of "dogmatic" or "superstitious". Sort of > like "build a wall". Walls are important for privacy and private property. I'm a posterboy for walls in terms of closed source. Without that wall, I'd be left to the whims of "leaders" like Obama. Brian Ebenezer Enterprises http://webEbenezer.net |
Christof Warlich <christof.warlich1@gmail.com>: Mar 23 06:49AM -0700 Hi, I'm trying to understand how to use functors with std::bind(). The following code defines a simple example class named "Offset" to instantiate three different functors being used to calculate its "result" member variable in three increasingly complex scenarios: #include <functional> #include <iostream> struct Offset { Offset(int offset): offset(offset) {} void operator()(int value) { result = offset + value; } int result; private: int offset; }; int main() { // scenario 1 Offset offset10(10); offset10(100); std::cout << "offset10(100) yields result " << offset10.result << std::endl; // scenario 2 std::function<void(int)> offset20(Offset(20)); offset20(100); std::cout << "offset20(100) yields result " << offset20.target<Offset>()->result << std::endl; // scenario 3 std::function<void()> offset100by30 = std::bind(Offset(30), 100); offset100by30(); std::cout << "offset100by30() yields result " //<< offset100by30.???->result << std::endl; return 0; } My issue is with scenario 3, i.e. when using std::bind(): How could I access the result member variable in this case? Please note that this is a contrived example to simplify things: I _do_ need a solution where Offset is passed as a temporary as shown, i.e. passing it as a reference would not be an option. Thanks for any help, Chris |
"Öö Tiib" <ootiib@hot.ee>: Mar 23 01:44PM -0700 On Wednesday, 23 March 2016 15:49:56 UTC+2, Christof Warlich wrote: > return 0; > } > My issue is with scenario 3, i.e. when using std::bind(): How could I access > the result member variable in this case? The type returned by 'std::bind' is of unspecified Callable type that is not required to have any methods of extracting what was bound into it. > Please note that this is a contrived example to simplify things: I _do_ > need a solution where Offset is passed as a temporary as shown, i.e. > passing it as a reference would not be an option. You assume a solution but do not describe a problem that it solves. What is the benefit of using 'std::bind'? I felt it as sort of obsolete with lambdas available. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 22 11:54PM Someone should make a post-apocalyptic comic about a world where Donald Trump was voted President and Jeremy Corbyn Prime Minister. I think they should call the comic "Radioactive Sausages". /Flibble |
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Mar 23 01:24AM +0100 On 23.03.2016 00:54, Mr Flibble wrote: > Someone should make a post-apocalyptic comic about a world where Donald > Trump was voted President and Jeremy Corbyn Prime Minister. > I think they should call the comic "Radioactive Sausages". You should read Robert Heinlein's "Friday", Leigh. It's not Friday yet. In the novel Friday is a female Artifical Person whose vocation is the time honored one of assassin. Her "family", that she's bought into, disavows her when they find out she's an AP. Assassin is OK, but AP? Oh noes. There's something about her employer, I don't recall, but anyway she's on the run because WWIII has broken out, and it's a corporate war of terrorist attacks, assassinations, stock market manipulation, politics, and not the least, deception and large scale propaganda. Physical money is being outlawed, in order to be able to track undesirables and possible problematic persons like her. Oh dang, that sounds familiar. Well. :) Cheers!, - Alf PS: I think Ben Bova also covered much the same angle on things. |
woodbrian77@gmail.com: Mar 22 07:44PM -0700 On Tuesday, March 22, 2016 at 6:55:03 PM UTC-5, Mr Flibble wrote: > Trump was voted President and Jeremy Corbyn Prime Minister. > I think they should call the comic "Radioactive Sausages". > /Flibble I like Ted Cruz. He would be an old school President -- hard working and humble. We need another decent President. Actually, the West needs another decent President. Please pray for Brussels and Paris. Brian Ebenezer Enterprises http://webEbenezer.net |
"Chris M. Thomasson" <nospam@nospam.nospam>: Mar 22 09:38PM -0700 > Someone should make a post-apocalyptic comic about a world where Donald > Trump was voted President and Jeremy Corbyn Prime Minister. > I think they should call the comic "Radioactive Sausages". Humm... http://southpark.cc.com/full-episodes/s19e02-where-my-country-gone ;^) |
scott@slp53.sl.home (Scott Lurndal): Mar 23 01:37PM >time honored one of assassin. Her "family", that she's bought into, >disavows her when they find out she's an AP. Assassin is OK, but AP? Oh >noes. There's something about her employer, I don't recall, but anyway Kettle Belly Baldwin. From an earlier Heinlein short "Gulf", originally. >Physical money is being outlawed, in order to be able to track >undesirables and possible problematic persons like her. >Oh dang, that sounds familiar. Well. :) _If this goes on..._ may be a more illustrative heinlein example of what might happen if Cruz or Trump win (only 4 years late compared to the 2012 election in the story). |
Gareth Owen <gwowen@gmail.com>: Mar 23 07:08PM >> /Flibble > I like Ted Cruz. He would be an old school President -- > hard working and humble. We need another decent President. Really? Because almost everyone who's ever met him - especially former classmates and Republicans who had to work him - thinks he's a total asshole. And "humble" is absolutely not one of the words they use. "If you killed Ted Cruz on the floor of the Senate, and the trial was in the Senate, nobody would convict you." -- Lindsey Graham |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 23 07:12PM > Please > pray for Brussels and Paris. Praying achieves absolutely nothing; if you really cared then you would do more than something that achieves absolutely nothing. /Flibble |
Gareth Owen <gwowen@gmail.com>: Mar 23 08:08PM >> Please >> pray for Brussels and Paris. > Praying achieves absolutely nothing Not true. It makes the pray-er feel better about themselves. |
woodbrian77@gmail.com: Mar 23 01:28PM -0700 On Wednesday, March 23, 2016 at 2:09:10 PM UTC-5, gwowen wrote: > asshole. And "humble" is absolutely not one of the words they use. > "If you killed Ted Cruz on the floor of the Senate, and the trial was in > the Senate, nobody would convict you." -- Lindsey Graham To his credit, Lindsey Graham has changed his mind and started fund raising for Ted Cruz. There's an article about that on www.dailywire.com . Brian Ebenezer Enterprises http://webEbenezer.net |
"Chris M. Thomasson" <nospam@nospam.nospam>: Mar 23 01:29PM -0700 > > I think they should call the comic "Radioactive Sausages". > Humm... > http://southpark.cc.com/full-episodes/s19e02-where-my-country-gone This episode is kind of amusing because a "Trump" like character is elected president of Canada, and builds a wall along the border with America. This character then pisses off basically everybody, and Canada is quickly thrown into disarray, with tumbleweeds blowing through the damn streets! Not nuclear war, but its still a bit interesting to me. ;^) |
Bob Langelaan <bobl0456@gmail.com>: Mar 23 11:36AM -0700 My students are normally able to figure out on their own any issues that arise while doing their assignments. But I had 3 different students run into this issue this semester and end up having to reach out to me for help. I believe that this is mostly caused by their inability to map the error message to their solution. Here is a very simplified version of the issue: class myClass { const int i; }; int main() { myClass a, b; a = b; } The code above generates 3 errors in MS VS 2015, all of which refer to "attempting to reference a deleted function". I must admit it took me a while to find the issue the first time. Realize that the code the student sent me was much more involved than the example above. Of course it can be argued that it is very rare (never?) that you would actually want to define and initialize a non-const data member in a class interface file. But these are students just learning the language and relatively new to object oriented programming as well and as such are more likely to make to make such a logic error (not defining a const member as static). My point is that students would be more likely to able to figure the issue on their own if the MS VS 2015 error messages were more illuminating. |
Bob Langelaan <bobl0456@gmail.com>: Mar 23 11:42AM -0700 On Wednesday, March 23, 2016 at 11:37:03 AM UTC-7, Bob Langelaan wrote: > I must admit it took me a while to find the issue the first time. Realize that the code the student sent me was much more involved than the example above. > Of course it can be argued that it is very rare (never?) that you would actually want to define and initialize a non-const data member in a class interface file. But these are students just learning the language and relatively new to object oriented programming as well and as such are more likely to make to make such a logic error (not defining a const member as static). > My point is that students would be more likely to able to figure the issue on their own if the MS VS 2015 error messages were more illuminating. There was an error in my original post. I meant to say (corrected part in CAPS): Of course it can be argued that it is very rare (never?) that you would actually want to define and initialize a CONST DATA MEMBER WHICH IS NOT STATIC in a class interface file. But these are students just learning the language and relatively new to object oriented programming as well and as such are more likely to make to make such a logic error (not defining a const member as static). |
Ian Collins <ian-news@hotmail.com>: Mar 24 08:28AM +1300 On 03/24/16 07:36, Bob Langelaan wrote: > } > The code above generates 3 errors in MS VS 2015, all of which refer > to "attempting to reference a deleted function". Firstly, please wrap your lines! Second try using an alternative compiler. The two I use make the cause much clearer: CC -std=c++14 ~/temp/c.cc "/home/ian/temp/c.cc", line 8: Error: a must be initialized. "/home/ian/temp/c.cc", line 8: Error: Constant members of 'myClass' must be initialized. "/home/ian/temp/c.cc", line 8: Error: b must be initialized. "/home/ian/temp/c.cc", line 8: Error: Constant members of 'myClass' must be initialized. "/home/ian/temp/c.cc", line 9: Error: Using deleted function 'myClass::operator=(const myClass&)'. and: g++ -std=c++14 ~/temp/c.cc /home/ian/temp/c.cc: In function 'int main()': /home/ian/temp/c.cc:8:10: error: use of deleted function 'myClass::myClass()' myClass a, b; ^ /home/ian/temp/c.cc:1:7: note: 'myClass::myClass()' is implicitly deleted because the default definition would be ill-formed: class myClass ^ /home/ian/temp/c.cc:1:7: error: uninitialized const member in 'class myClass' /home/ian/temp/c.cc:3:12: note: 'const int myClass::i' should be initialized const int i; ^ /home/ian/temp/c.cc:8:13: error: use of deleted function 'myClass::myClass()' myClass a, b; ^ /home/ian/temp/c.cc:9:4: error: use of deleted function 'myClass& myClass::operator=(const myClass&)' a = b; ^ /home/ian/temp/c.cc:1:7: note: 'myClass& myClass::operator=(const myClass&)' is implicitly deleted because the default definition would be ill-formed: class myClass ^ /home/ian/temp/c.cc:1:7: error: non-static const member 'const int myClass::i', can't use default assignment operator -- Ian Collins |
ram@zedat.fu-berlin.de (Stefan Ram): Mar 23 04:13AM >Inheritance is fundamental to object oriented paradigm What is fundamental is, er, polymorphism. Implementation inheritance can be used to implement polymorphism, but polymorphism can also be implemented by interface inheritance or by duck typing (pure run-time typing). Actually, the last way is the historic way of Smalltalk. Static types were then added to add additional compile-time type safety. >composition is fundamental to any software design paradigm By the way, there is not only inheritance and composition, but also delegation. Delegation is not just another name for composition, but a special pattern that »simulates« more properties of inheritance, delegation is based on composition, but it goes beyond mere composition (see Gamma et al.). >We can not solve a OOP question if >square is kind of rectangle or not When we have a /source/ for squares, this can also be seen as a source for rectangles. That is, if one defines auto isSquare = []( auto x ){ return x.getWidth() == x.getHeight(); } auto isRectangle = []( auto x ){ return true; } then isSquare( x ) implies isRectangle( x ). (Simplified: »Every square is a rectangle.«) When we have a /sink/ for rectangles, this can also be seen as a sink for squares. That is, we can use an object with the interface struct rectangle_sink { virtual void setWidth( int width ) = 0; virtual void setHeight( int height ) = 0; }; as a sink for a square as follows: sink.setWidth( square.getExtension() ); sink.setHeight( square.getExtension() ); (Simplified: »Every rectangle is a square.«) . However, when something is /both/ a source and a sink, then neither is a subset of the other. |
ram@zedat.fu-berlin.de (Stefan Ram): Mar 23 02:02PM >std::function<void()> offset100by30 = std::bind(Offset(30), 100); >I _do_ need a solution where Offset is passed as a temporary If want to access a member of it after it has been evaluated, it can't be a temporary. |
ram@zedat.fu-berlin.de (Stefan Ram): Mar 23 07:13PM > myClass a, b; > a = b; >} The compiler would usually create an assignment function: my_class & operator=( const my_class & x) { i = x.i; return *this; } . In this function, an assignment to a read-only member is attempted. This would be ill-formed. So this assignment operator becomes implicitly deleted. |
wij@totalbb.net.tw: Mar 22 11:34PM -0700 Xn project (version 0.03) is released. https://sourceforge.net/projects/systemnode/ Xn project tries to develop a nodal language protocol capable for almost all kinds of data storage and communication. Written languages can be in any natural language, can be various kind of file format, executable scripts (even alive). |
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