- "Linus Torvalds Was (Sorta) Wrong About C++" - 8 Updates
- Need Help with design of class hierarchy - 1 Update
- Getters & Setters argument - 2 Updates
- Can 'this' be assigned a pointer to it? - 9 Updates
- Cgi and c++ - 2 Updates
- template matching problem - 3 Updates
Lynn McGuire <lmc@winsim.com>: Mar 11 12:29PM -0500 "Linus Torvalds Was (Sorta) Wrong About C++" http://news.dice.com/2015/03/10/linus-torvalds-was-sorta-wrong-about-c/ "With all the new (and new-ish) languages out there, you might wonder why it's still worth learning C++, a language first invented in 1983. Wedged amidst lower-level languages such as C, C++ went through a spike in popularity in the mid-'90s, when developers realized it was easily translatable to assembly language; but today's higher-level languages abstract the processor even further away." "Systems-level programming probably still needs C, but for high-level applications, C++ is a great choice. And judging by the number of C++ jobs today, the language is not going away anytime soon. Now is still a great time to learn this older programming language; don't let the famous naysayers and their profane soliloquies about inelegance dissuade you." Lynn |
scott@slp53.sl.home (Scott Lurndal): Mar 11 05:45PM >"Systems-level programming probably still needs C, but for high-level applications, C++ is a great choice. And judging by the number >of C++ jobs today, the language is not going away anytime soon. Now is still a great time to learn this older programming language; >don't let the famous naysayers and their profane soliloquies about inelegance dissuade you." There is really no reason that systems-level programming cannot also be done in C++. I've two operating systems and two hypervisors to prove it... |
Greg Martin <greg.at.softsprocket@dot.com>: Mar 11 05:53PM > "Systems-level programming probably still needs C, but for high-level applications, C++ is a great choice. And judging by the number > of C++ jobs today, the language is not going away anytime soon. Now is still a great time to learn this older programming language; > don't let the famous naysayers and their profane soliloquies about inelegance dissuade you." Much of what Torvalds has said on the subject was designed to get the people who were pestering him to switch to /their/ choice of a language to go away, at least that was what I took away from it when I read the thread it occurs in. He is happy with the choice of C for git and the Linux kernel and doesn't wish to switch; end of story. -- http://www.softsprocket.com |
Johannes Bauer <dfnsonfsduifb@gmx.de>: Mar 11 07:12PM +0100 On 11.03.2015 18:45, Scott Lurndal wrote: > There is really no reason that systems-level programming cannot > also be done in C++. I've two operating systems and two hypervisors > to prove it... It's besides the point. Nobody -- especially not Linus -- is arguing that it cannot be done. Of course it can be done. Hell, I can write a complete DBMS in Itanium assembly or I can write a C++ compiler in GWBasic. All Linus is saying is that he WON'T. Judging from the amount of extrodinarily shitty C++ code I have seen in my life, I kind of understand why. Cheers, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1@speranza.aioe.org> |
Wouter van Ooijen <wouter@voti.nl>: Mar 11 07:37PM +0100 Johannes Bauer schreef op 11-Mar-15 om 7:12 PM: > All Linus is saying is that he WON'T. Judging from the amount of > extrodinarily shitty C++ code I have seen in my life, I kind of > understand why. That's like saying that paper is generally used for wiping your ****, so something written on paper must be shitty. I sort of agree that C++ is a crappy language, but as that is mostly due to its C legacy, I am not gona take such insults from a C lover! (For the record: C++ is may favourite language, crappy or not, for resource-constrained work. For other work I tend to use Python (which has its own unqiue share of crappyness.) Wouter van Ooijen |
JiiPee <no@notvalid.com>: Mar 11 06:46PM On 11/03/2015 17:45, Scott Lurndal wrote: > There is really no reason that systems-level programming cannot > also be done in C++. I've two operating systems and two hypervisors > to prove it... if a hardware has very little memory, creating a C array is: char a[10]; Thats 10 bytes in C++ it might be: array<int> a(10); Which take objects allocation (couple of bytes) plus 10. So C makes shorter executable what many want. |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 11 06:56PM On 11/03/2015 18:46, JiiPee wrote: > array<int> a(10); > Which take objects allocation (couple of bytes) plus 10. So C makes > shorter executable what many want. Wrong. The size of "char a[10]" will likely be the same as the size of "std::array<char> a;". A std::array does not perform any allocations; it's storage is inline just like for a C style array. /Flibble |
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Mar 11 06:57PM On 11/03/2015 18:56, Mr Flibble wrote: > Wrong. The size of "char a[10]" will likely be the same as the size of > "std::array<char> a;". A std::array does not perform any allocations; > it's storage is inline just like for a C style array. Er, I of course meant "std::array<char, 10> a;". /Flibble |
sdubak4@gmail.com: Mar 11 11:32AM -0700 Hi, I am having a difficult time figuringout how I'm going to design my base and derived classes for a specific project. What I'm looking to do is come up with a design for an efficient OO class design to represent songs in an Artists catalog. Songs at te lowest level. Then Discs becasue each song is contained on a disc within a particular release by the artist. And there are multiple releases. And multiple artists. Here's a very simplified example of what I've been thinking of. Hopefully this will be readable and understandable to everyone: class Song // every song has it's own class string &name; // full path to song on disk. virtual GetRelease(); // With a pointer to any Song class, one virtual GetArtist(); // could obtain the Disc, Release and virtual GetFullPath(); / /Artist associated with that song. class Disc : Song // Each Release has at least 1 disc virtual int GetDiscNumber(); class Release : Song virtual string& GetFullPath(); virtual string& GetRelease(); // Get name of the Release class Artist : Release virtual string& GetArtist(); With the above simplistic design, if you have pointer to a Song class, you can get the Artist name and the name of the Disc, Release and Artist. What I don't like about it though is that to represent an entire I would need name instances of the Artist class. I would need an instance of the artist class for every song on that particular Release. Then to represent the Artists entire music collection, I would need an Artist class for every song in the artists catalog. The same is true for all classes up the hierarchy. An artist has many releases An alternative. class Song string &name; class Disc array<Song*> songs; class Release array<Disc*> discs; class Artist array<Release*> releases; What I fdon't like about the above design is that there's not any OO'ness about it. array's could be lists, doesn't matter. If I have a pointer to a Song class, I don't have any oter information about the song. I can't get the Artist name, the release it came from, etc ... But what's good about it, as compared to the first example, is I only have 1 instance of the Artist class for each and every artist. Looking for suggestions on how one would go about designed a good class hierarchy to represent the music of a particular recording artist. Any suggestion greatly appreciated. Scott |
Reinhardt Behm <rbehm@hushmail.com>: Mar 11 10:39AM +0800 Stefan Ram wrote: > int main() > { int x; > ^ Warning: Raw int used. (Raw ints will be deprecated in C++2z.) And at the highest warning level: ** Warning you are writing a program. It might contain errors. -- Reinhardt |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Mar 11 05:59PM On Tue, 2015-03-10, Stefan Ram wrote: >>type for this thing I'm modelling, rather than let it join and mingle >>with the other happy integers?" > You seem to agree with Bjarne! Partly, I suspect, because a adopted his use of the word "type". But yes, he also writes somewhere in TC++PL that working with a lot of what he calls "concrete types" is important, and I agree fully with that. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
fl <rxjwg98@gmail.com>: Mar 10 10:29PM -0700 Hi, I read C++ for some time, but I still has problem in understand it. Below is from web tutorial. It requires to debug it, but I cannot figure out what is wrong with the void change function. The error message says that this must be a lvalue. Does that mean 'this' cannot be assigned a value? Then the change function is invalid? What it wants me to do? Please at least give a little hint on it. thanks, #include<iostream> using namespace std; class Test { private: int x; public: Test(int x = 0) { this->x = x; } void change(Test *t) { this = t; } void print() { cout << "x = " << x << endl; } }; int main() { Test obj(5); Test *ptr = new Test (10); obj.change(ptr); obj.print(); return 0; } |
"Norman J. Goldstein" <normvcr@telus.net>: Mar 10 10:59PM -0700 On 03/10/2015 10:29 PM, fl wrote: > obj.print(); > return 0; > } There are a couple of things, here, that are confusing: 1. Overusing the variable name, 'x'. Change the declaration of Test to be Test( int x0 = 0 ); 2. The rules don't allow you to assign to "this". However, you can pass around &obj and ptr inside the main function to change which Test object you are working with. |
Robert Wessel <robertwessel2@yahoo.com>: Mar 11 01:00AM -0500 On Tue, 10 Mar 2015 22:29:48 -0700 (PDT), fl <rxjwg98@gmail.com> wrote: > obj.print(); > return 0; >} "9.3.2 The this pointer In the body of a nonstatic (9.3) member function, the keyword this is a nonlvalue expression whose value is the address of the object for which the function is called." this is not an lvalue, IOW, you can't modify it. |
JiiPee <no@notvalid.com>: Mar 11 07:24AM On 11/03/2015 06:00, Robert Wessel wrote: > a nonlvalue expression whose value is the address of the object for > which the function is called." > this is not an lvalue, IOW, you can't modify it. a good answer, +1 :) |
"Lőrinczy Zsigmond" <zsiga@nospam.for.me>: Mar 11 10:16AM +0100 This code wouldn't do any good, even if worked: void change(Test *t) { this = t; } But this version would do something mode-or-less useful: void change(Test *t) { *this = *t; } |
Martijn Lievaart <m@rtij.nl.invlalid>: Mar 11 10:47AM +0100 On Tue, 10 Mar 2015 22:29:48 -0700, fl wrote: > I read C++ for some time, but I still has problem in understand it. > Below is from web tutorial. It requires to debug it, but I cannot figure > out what is wrong with the void change function. Others pointed out the problem itself, just wanted to point out that a tutorial that makes such basic errors should be ditched immediately. M4 |
Melzzzzz <mel@zzzzz.com>: Mar 11 04:19PM +0100 On 3/11/15 6:29 AM, fl wrote: > obj.print(); > return 0; > } `this` is just syntactic sugar for first parameter of function. say func(Test* this) .... Even if you assign value to it nothing will change. |
Haddock <ffm2002@web.de>: Mar 11 09:39AM -0700 Assigning a different reference to the this pointer is like, say, assigning 5 to 3. Then everywhere in your system every 5 is now a 3. This is something that shouldn't be done. Needless to say that the application would also shut down immediately if every 5 would be a 3 from now on. I don't know whether this sample is meaningful, but I think you know what I mean. |
Greg Martin <greg.at.softsprocket@dot.com>: Mar 11 04:48PM >> out what is wrong with the void change function. > Others pointed out the problem itself, just wanted to point out that a > tutorial that makes such basic errors should be ditched immediately. The tutorial was suggesting the user should debug the program so it would make sense there should be an error for the reader to fix. -- http://www.softsprocket.com |
Tomas Garijo <tgarijo@gmail.com>: Mar 11 09:16AM -0700 Hello, I'm noob in c++. My problem is next. A linux system, is sending to my apache server a xml stream by http post. I need capture by CGI this stream xml and parsec it, but i don't know how to do this. The major problem is capture the xml stream. I don't know if i need a GCI API or Socket API. Please can you help me? Regards. |
"Lőrinczy Zsigmond" <zsiga@nospam.for.me>: Mar 11 05:22PM +0100 In CGI, the POST-data comes from the standard input, so simply use fgets/fread/etc on standard input. |
"Norman J. Goldstein" <normvcr@telus.net>: Mar 10 06:34PM -0700 Below, is code that has 4 different conditional compilation blocks. When the first block is chosen, the compilation breaks with the msg: error: template-id 'copy<>' for 'bool copy(WD&, WD::IoRefrType<A>)' does not match any template declaration template bool copy( WD&, which refers to the inability of the compiler to explicitly instantiate, as requested at the bottom of the source code. However, when any of the last 3 blocks is chosen, instead, the compilation is fine. I am using gcc 4.8.3 on linux x86-64. Explanations or suggestions much appreciated! /////////////////////// source code /////////////// struct WD { template< typename T > using IoRefrType = const T&; }; class A; #if 1 // Two template parameters: Error template< typename S, typename T > bool copy( S& s, typename S:: template IoRefrType< T > t ) { return true; } #elif 1 // Only the first template parameter: OK template< typename S > bool copy( S& s, typename S:: template IoRefrType<A> ) { return true; } #elif 1 // Only the second template parameter: OK template< typename T > bool copy( WD& , typename WD:: template IoRefrType< T > t ) { return true; } #else // Simpler two template parameters: OK template< typename S, typename T > bool copy( S& s, const T& t ) { return true; }
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment