Flylib.com

Books Software

 
 
 

Essential COM - page 9

, . , ÷.

, « Delphi» (http://delphi.vitpc.com), , Data Art, .

ø ÷, , ÷ comp@piter.com ( «», ).

ø !

ø Web- http://www.piter.com.

, , http://www.piter.com/download

1. ÷ø C++

template <class Т, class Ex> 
class list_t : virtual protected CPrivateAlloc { 
    list<T**> m_list;
    mutable TWnd m_wnd; 
    virtual ~list_t(void);
  protected: 
    explicit list_t(int nElems, ...);
    inline operator unsigned int *(void) const 
      { return reinterpret_cast <int*>(this) ; } 
    template <class X> void clear(X& rx) const throw(Ex);
};

Аноним, 1996

C++ . C++ ø, ø ø . ß C++ ÷ , , Bell Laboratories, C++ (CFRONT), C++. ø C++ 1980- ÷ 1990- . ÷ C++ ( ÷ ÷ ÷ C++) ÷ UNIX , . ß, ÷ , , C++.

C++ , ( user -defined types - UDTs), . , , . C++ C++ ø, . ÷ . ÷ , , NIH- (not invented here - « ») ÷ C++. ÷ ÷ , ÷ . ÷ ÷. ÷ ÷ , ÷ . - (wrappers), , ÷ , , .

: ÷ , ÷ . « » ÷ ÷ , ÷ ÷ ÷ . ÷ . ø ÷ , . , ÷ ÷ ÷ , « », ÷ø , .

(reuse) ÷ . , C++, , . , ( design-time ) ( development-time ), ÷ ÷ C++, ø ÷ (runtime), ÷ C++ . , C++. ÷ C++ . ÷ ø , (off-the-shelf) . , , , , ÷ ÷ .


÷ ++
÷ ++
C++
++

÷

ø

?

÷ ++

, C++ , , C++ 1980- . ÷ , O(1) ( , ). , , ÷. ÷ , ÷ , , (fast text strings) . × , ÷ ÷ , :

// faststring.h 
class FastString { 
    char *m_psz; 
  public: 
    FastString(const char *psz); 
    ~FastString(void); 
    int Length(void) const;
      // returns # of characters 
      // возвращает число символов 
    int Find(const char *psz) const;
      // returns offset 
      //возвращает смещение 
};

, ÷ -÷ :

// FastString.cpp 
#include "faststring.h" 
#include <string.h> 

FastString::FastString(const char *psz) : m_psz(new char [strlen(psz) + 1]) 
  { strcpy(m_psz, psz); } 

FastString::~FastString(void) 
  { delete[] m_psz; } 

int FastString::Length(void) const 
  { return strlen(m_psz); } 

int FastString::Find(const char *psz) const 
{ 
    //O(1) lookup code deleted for>
clarity

1

// код поиска 0(1) удален для ясности
}

C++ . , ÷ ÷ , C++. , ÷ C++, . , ÷ ÷ .

, ÷ ø FastString ø ÷ 16 . , ÷ O(1)- , ÷ ÷ , - , ÷ ø . . 1.1, FastString , ÷ 16 . ÷, ÷ ÷ , FastString 48 . - ÷ , FastString 48 , , .

 1.1. faststring

: ÷ FastString , . FastString , ø FastString ÷ . ÷ ÷ , ÷ , ÷ ÷ . ß, ÷ FastString ÷ , .


1 , . ÷.

÷ ++

ø - FastString ÷ ÷ (Dynamic Link Library - DLL). . ø - , , ÷ FastString DLL. Microsoft C++ ÷ _declspec(dllexport) :

class _declspec(dllexport) FastString { 
    char *m_psz; 
  public: 
    FastString(const char *psz); 
    ~FastString(void);
    int Length(void) const;
      // returns # of characters 
      // возвращает число символов 
    int Find(const char *psz) const; 
      // returns offset 
      // возвращает смещение
};

÷ FastString DLL, ÷ . , (import library), FastString . ÷ , ÷ DLL . , . ÷ ÷ DLL FastString ÷ . ÷ .

1.2 FastString (runtime model), DLL. , ÷ ÷ ( ø, ÷ ). DLL, FastString . , ÷ ÷ , ÷ ÷ , FastString ( ÷), . , ÷ , ÷ DLL ÷ , . ß, ÷ FastString DLL ø C++ .

. 1.2. faststring dll