srichter wrote:

>Here is a c++ string class:
>Class String {
>// two data mbrs. lgth of the string and
>// a ptr to string data.
>  int mnLgth ;
>  char* mpData ;
>// an assignment member function.
>// user of the class codes as: string1 = string2
>// ( some confusing symbols left out )
>String operator=( const String string2 ) ;
>} ;
>// here is the assignment mbr function code.
>String String::operator=( const string2 )
>if ( mpData != NULL )
>  {
>  free( mpData ) ;  // free old string
>  }
>// allocate string memory.
>  mnLgth = string2.GetLgth( ) ;
>  mpData = malloc( mnLgth + 1 ) ;
>// store the string value.
>  strcpy( mpData, string2.GetBuffer( ) ) ;
Isn't your contention that the method strcpy is not as efficient as the
MI call? So why doesn't that method implement the MI call?

>return *this ;
>The string class is then used in a pgm:
>  String sEvilDoer ;
>  sEvilDoer = "Ibm leadership" ;
>This code takes a lot of cpu to run, is bloat free, abstracts away a bunch of 
>details the pgmr does not need to have deal with, does not give much chance to 
>optimize and would make our as400 grind to a halt if run as frequently as 
>efficient RPG pgms are run.
Why does this code take a lot of cpu to run?

>Steve Richter

Chris Rehm

Beloved, let us love one another: for love is of God; and every one
that loveth is born of God, and knoweth God. 1 John 4:7

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.