TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: All
from: Tom Brown
date: 1996-01-21 02:01:04
subject: C++ Question

Hi:

I have been using C++ for some time now.  As a long-time C programmer,
I don't use the object oriented features as much as I might.  It seems
as though a simple program with no templates, OpenClass objects or
containers comes out much larger than it ought to.

What I like most about the language is the way it lends itself to
grouping related functions.  My code looks like C code except I do use
cout and cerr all of the time.  I've often wondered why a simple
program with a main() and one object with four methods (functions to
me) needs to be 40K when the same thing in C comes in at 14K.  I don't
mean a similar thing in C.  If you take the C++ object and simply
break it down into the four functions and compile the whole works as C
code, it comes in a bunch smaller.  The size increase with C++ starts
with larger .OBJs and more run-time code is linked in, as well.

I know that with C, I need to keep each function in it's own source
file so that the linker can link in only the functions that it needs. 
I'm talking about object libraries specifically.  C++ seems to get out
of hand if you put each method into it's own source file.  I've got
some pretty big objects (all in one source file -> a .CPP and a .HPP),
so I'm guessing that if I instantiate one of these bad boys I get the
whole thing regardless of what methods are called in my application.

Curiously, I find the performance of C++ to be very near C when I
don't use C++ specific features, even though the .EXEs are larger.  I
don't care about hard disk space, but I would like to code as
efficiently as I can.  Perhaps someone could shed some light on this,
point me to a resource on this subject or, heaven forbid, tell me what
I'm doing wrong.  So far, my main C++ reference has been Stroustrup's
second edition.  My compiler is IBM VA C++.

BTW, I realize that a more powerful language will tend to generate
more .EXE per line of code.  With C++ having the capability to be so
similar to C though, I can't help but wonder.  Thanks in advance.


Best wishes,

Tom

 * KWQ/2 1.2g * Liberace was great on the piano, but sucked on the
organ.
--- GEcho/2 1.20/Pro
* Origin: The Green Zone (1:140/23)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 140/23 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.