Welcome to EZDefinition.com
Technological Concepts, Abbreviations & Definitions
Main Menu
Main categories
  • Operating Systems
  • Computer Hardware
  • Internet
  • Programming Languages
  • Multimedia
  • Software
  • Security and Encryption
  • Communications and Networking
  • Organizations
  • Books
  • Databases
  • Games
  • E-commerce

    [an error occurred while processing this directive]

  • EZDefinition Sponsor
    Please visit our sponsor Parosoft.com
    Related Links to Non-inline function definitions
    [an error occurred while processing this directive]
    Non-inline function definitions
    [an error occurred while processing this directive]
    Computer Technologies  Programming Languages  C++ Non-inline function definitions

    Non-inline function definitions

    Non-inline function definitions

    Of course, there are times when you’ll want to have non-inline member function definitions. In this case, the compiler needs to see the template declaration before the member function definition. Here’s the example above, modified to show the non-inline member definition:

    //: C16:Array2.cpp
    // Non-inline template definition
    #include "../require.h"
     
    template<class T>
    class Array {
      enum { size = 100 };
      T A[size];
    public:
      T& operator[](int index);
    };
     
    template<class T>
    T& Array<T>::operator[](int index) {
      require(index >= 0 && index < size,
        "Index out of range");
      return A[index];
    }
     
    int main() {
      Array<float> fa;
      fa[0] = 1.414;
    } ///:~

    Any reference to a template’s class name must be accompanied by its template argument list, as in Array<T>::operator[]. You can imagine that internally, the class name is being decorated with the arguments in the template argument list to produce a unique class name identifier for each template instantiation.

     


    [an error occurred while processing this directive]

    [an error occurred while processing this directive]
     

    All Rights Reserved

    Terms of usage   Please read our privacy stetment
    Copyright © 1999-2006 EZDefinition.com

     

    [an error occurred while processing this directive]