[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: }Re: [Sheflug] c++ & mem
On Sat, 9 Dec 2000, Alex Hudson wrote:
> Yes. C and C++ programs are written differently, and end up with different
> binaries, link differently, etc. etc. Witness the trouble RH got into with
> 7.
Which if anything had more to do with paranoid Red Hat haters than
anything else.
> > Often you have to be explicit about it though (i.e. use flags).
>
> Example?
-fno-rtti
> Nope. Trying to do C++ features in C is called "c-front", and it isn't great
> (being polite). structs do not replicate objects, they don't even come
> close. They can't encapsulate code (don't give me pointers to functions),
Pointers to functions are a valid way of doing things. And one of the main
reasons Java sucks so badly.
> they don't data hide, they don't inherit, etc. etc. People write:
> type func(types.. )
> {
>
> }
Data hiding as a language feature is for idiots. If you don't want to
access private data, don't do it. Write up macros thus:
struct foo {
int bar;
};
#define FOO_BAR(x) x.bar
It's fast and clean. No, it doesn't have any compile time or run time
checks, but you can write good code without it.
> . because the { on it's own line signifies start of function. This is often
> used to signify the fact that you can't nest functions. C has all sorts of
Sounds like "Computer Science" to me...
> limits like this which just aren't there in C. OO certainly isn't a frame of
> mind, it requires language support to be done properly. Perl isn't OO,
> neither is C. It is *possible* to write OO type programs in either language,
> but you end up replicating the OO functionality yourself. That isn't the
> same as the language being OO.
Any sane definition of OO vs. fucntional vs. structured
will allow you to write OO code in C.
> man gcc: first line of description:
> "the C and C++ compilers are integrated".
> . they just use different linkers, a lot of the rest of it is identical.
Different linkers? Are you sure?
> Hmmm. It's "ugly", therefore it doesn't work. :) Not sure I agree with that,
> either. And how
> cout << "Value of myvar: " << myvar;
> is "uglier" than
> fprintf(stdout, "Value of myvar: %d", myvar);
> . I'll never know ;)
Hmmm, try outputting it as hex, or as a floting point value to a certain
precision. You can, but it takes twice as much code.
---------------------------------------------------------------------
Sheffield Linux User's Group - http://www.sheflug.co.uk
To unsubscribe from this list send mail to
- <sheflug-request [at] vuw.ac.nz> - with the word
"unsubscribe" in the body of the message.
GNU the choice of a complete generation.