From owner-freebsd-questions@FreeBSD.ORG Wed Nov 12 19:24:26 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0C94116A4CE for ; Wed, 12 Nov 2003 19:24:26 -0800 (PST) Received: from out003.verizon.net (out003pub.verizon.net [206.46.170.103]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7989343FE3 for ; Wed, 12 Nov 2003 19:23:59 -0800 (PST) (envelope-from leblanc@keyslapper.org) Received: from keyslapper.org ([68.160.42.77]) by out003.verizon.net (InterMail vM.5.01.05.33 201-253-122-126-133-20030313) with ESMTP id <20031113032358.EWZS1420.out003.verizon.net@keyslapper.org> for ; Wed, 12 Nov 2003 21:23:58 -0600 Received: from keyslapper.org (localhost [127.0.0.1]) by keyslapper.org (8.12.8p1/8.12.8) with ESMTP id hAD3O24Q034601 for ; Wed, 12 Nov 2003 22:24:03 -0500 (EST) (envelope-from leblanc@keyslapper.org) Received: (from leblanc@localhost) by keyslapper.org (8.12.8p1/8.12.8/Submit) id hAD3O294034598 for freebsd-questions@freebsd.org; Wed, 12 Nov 2003 22:24:02 -0500 (EST) Date: Wed, 12 Nov 2003 22:24:02 -0500 From: Louis LeBlanc To: freebsd-questions@freebsd.org Message-ID: <20031113032401.GA34467@keyslapper.org> Mail-Followup-To: freebsd-questions@freebsd.org References: <200311130137.hAD1bUg02673@gateway.home> <2721593A-1582-11D8-BB00-0030656DD690@foolishgames.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <2721593A-1582-11D8-BB00-0030656DD690@foolishgames.com> User-Agent: Mutt/1.5.5.1i X-Authentication-Info: Submitted using SMTP AUTH at out003.verizon.net from [68.160.42.77] at Wed, 12 Nov 2003 21:23:58 -0600 Subject: Re: Newbie: The C / C++ Issue X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: freebsd-questions@freebsd.org List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Nov 2003 03:24:26 -0000 On 11/12/03 09:36 PM, Lucas Holt sat at the `puter and typed: > > On Nov 12, 2003, at 8:37 PM, Marty Leisner wrote: > > > > > > > BTW -- I've been doing "object oriented" stuff in C for years -- > > its harder, but its doable. You have a much simpler language to > > deal with. > > > > First learn how to write good programs in C. Then see if C++ buys > > you anything extra. If it doesn't, you don't need C++. But I've > > seen far too much C++ that's just obscure C. > > > > Just my experience and opinion. > > > > marty > > Am I missing something here? When does C have OO capability? > Structs don't count. What about inheritance and polymorphism? That's in the implementation AND application. Just because you CAN access part of a lowly struct, doesn't mean you have to. It's object oriented if you OBSERVE the restricted accesses defined by OO. Whether or not they're there is completely irrelevant. Of course C has OO capability, it just doesn't have its restrictions :) > To me a struct is like a VCR with no record button. You can view > the content, but you can't manipulate it with the struct. If i want > to do something to destroy the tape, I must apply a magnet from an > outside source (much like a plain old function). And classes > provide security, much like the tab on the front of the tape. The > data is private if the tab is puched out. (ok thats a bad analogy) Seems to me it's more like a VCR tape with the tab taped over. If you declare a struct, and then implement a specific set of routines to manipulate it, and only use those routines, except for those 'data members' that would otherwise be public anyway, that's essentially your class. You're doing without all the type and access restrictions IMPOSED by C++, but that doesn't mean you can't OBSERVE those restrictions. This way, when saving cpu time is critical, you can bend those rules. With C++, you're stuck on the long road. > If C had OO features, then why do we have C++ and Objective C? Because some people like C++ better. > I would agree that you can write programs that do the same thing in > all three languages above, but I don't think that OO is a waste of > time. OO promotes code reuse. That is the whole point. No one ever claimed OO was a waste of time that I noticed. But I don't see code reuse with C++ any more than with C. I'm a real big fan of code reuse, and I have reused more C code than I can remember. Problem is that when C++ code gets reused, it's usually a template class, in which case, you'd probably be better off with C anyway. When I reuse C code, it's a copied data structure and a set of routines that will apply to the task at hand, not a third generation inherited template class with half it's methods redefined. > Using C++ implies a state of mind. You can write code like in C, > but it defeats the purpose of using an OO language. Not sure what you mean by this, but if using C++ is a state of mind, why can't that state of mind affect the way C code is written? And it doesn't defeat the purpose if you misbehave regularly and NEED the unbreakable restrictions. Just another $0.02 L -- Louis LeBlanc leblanc@keyslapper.org Fully Funded Hobbyist, KeySlapper Extrordinaire :) http://www.keyslapper.org ԿԬ You're a good example of why some animals eat their young. -- Jim Samuels to a heckler