OOP & compact routines

ctl8588@rigel.tamu.edu (LAUGHLIN, CHET)
Thu, 09 Aug 90 18:04:36 GMT

          From comp.compilers

Related articles
OOP & compact routines ctl8588@rigel.tamu.edu (1990-08-09)
Re: OOP & compact routines burley@world.std.com (1990-08-10)
| List of all articles for this month |

Newsgroups: comp.compilers,comp.lang.c++
From: ctl8588@rigel.tamu.edu (LAUGHLIN, CHET)
Keywords: code,C++
Organization: TAMU
Date: Thu, 09 Aug 90 18:04:36 GMT

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
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.