Xref: utzoo comp.compilers:1110 comp.lang.c++:8908 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!snorkelwacker!spdcc!esegue!compilers-sender From: ctl8588@rigel.tamu.edu (LAUGHLIN, CHET) Newsgroups: comp.compilers,comp.lang.c++ Subject: OOP & compact routines Keywords: code,C++ Message-ID: <1990Aug09.180436.18715@esegue.segue.boston.ma.us> Date: 9 Aug 90 18:04:36 GMT Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: ctl8588@rigel.tamu.edu (LAUGHLIN, CHET) Organization: TAMU Lines: 39 Approved: compilers@esegue.segue.boston.ma.us Hello. I am thinking about writing a rather complex program using C++; however, I am concerned with the amount of code that I see being generated by the compiler. I am especially concerned with how compact the code will be to handle many classes of similar objects that differ only in small ways when actions are performed on them. For example, If I was to code a routine that would generate output for three types of objects it might look like this.... switch(curr_object) { case a: printf("howdy"); break; /* excuse the format...saving */ case b: printf("hello"); break; /* space here */ case c: printf("hi"); break; case d: printf("goodbye"); break; } Now, in C++ I would have a,b,and c inherit the same characteristics from some global class. From the literature I've seen I am lead to believe that all the code for an object is black boxed together...So I would see the following effect produced by the compiler. greeting(curr_object); /* Tell object to say hi */ /* apologies for bad syntax...I've not */ ..... /* actually programmed in C++ yet...*/ switch(curr_object) { /* compiler translates it to this... */ case a: actiona(); break; case b: actionb(); break; case c: actionc(); break; case d: actiond(); break; } Someone please tell me that this doesn't happen. This seems like a mountain of overhead to me to perform any actions. Apologies for any incorrect syntax/wrong usage of terms. -Chet Laughlin -- Send compilers articles to compilers@esegue.segue.boston.ma.us {spdcc | ima | lotus| world}!esegue. Meta-mail to compilers-request@esegue.