title: How am I supposed to declare this C++ function?
body: <p>I have a C++ program with an undefined reference error on the call of a method in a class. As near as I can tell, the method is public and I'm calling it with a parameter declared the same as the method definition, but eclipse/gcc tells me it is undefined. I'm not used to C++, can someone please tell me what's wrong with the definition?</p>
  <p>The main class:</p>
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  #include &quot;AttenuationConfigurationTable.h&quot;
  
  int main()
  {
    flash_entry_struct flash_array[] = { { 10, 20, 30, 40 }, { 50, 60, 70, 80 }, { -1, -1, -1, -1 } };
  
    // note: no undefined reference or any other error for the line with the class
    AttenuationConfigurationTable attConfigTable;
    // error appears for next line: undefined reference to ...load_attenuation_...
    attConfigTable.load_attenuation_calibration_table_from_flash(flash_array);
    return 0;
  }
  </code></pre>
  <p>The class file:</p>
  <pre><code>#include &quot;AttenuationConfigurationTable.h&quot;
  #include &quot;flashEntryStruct.h&quot;
  
  AttenuationConfigurationTable::AttenuationConfigurationTable() {    }
  
  AttenuationConfigurationTable::~AttenuationConfigurationTable() {    }
  
  class Attenuation_configuration_table
  {
    struct attenuation_voltages_struct
    {
      float att_value;
      float v1;
      float v2;
    } ;
  
    struct frequency_tables_struct
    {
      int frequency;
      attenuation_voltages_struct attenuation_voltages[100];
      int      voltages_count = 0;
    } ;
  
    frequency_tables_struct _frequency_tables[42];
  
    public:
  
    /************************************************************************/
    /* load the table in this object from the given flash memory address    */
    /************************************************************************/
    void load_attenuation_calibration_table_from_flash(flash_entry_struct memory_address[])
    {
      // bunch of logic here...
    }
  };
  </code></pre>
  <p>The h file for the class:</p>
  <pre><code>#ifndef ATTENUATIONCONFIGURATIONTABLE_H_
  #define ATTENUATIONCONFIGURATIONTABLE_H_
  
  #include &quot;flashEntryStruct.h&quot;
  
  class AttenuationConfigurationTable
  {
  public:
    AttenuationConfigurationTable();
    virtual ~AttenuationConfigurationTable();
    void load_attenuation_calibration_table_from_flash(flash_entry_struct flash_memory_address[]);
  };
  
  #endif /* ATTENUATIONCONFIGURATIONTABLE_H_ */
  </code></pre>
  <p>And, just for completeness, the h file defining the parameter structure:</p>
  <pre><code>#ifndef FLASHENTRYSTRUCT_H_
  #define FLASHENTRYSTRUCT_H_
  
    struct flash_entry_struct
    {
      uint16_t  frequency;
      uint16_t  scaled_db;
      int8_t    v1_byte;
      int8_t    v2_byte;
    } ;
  
  #endif /* FLASHENTRYSTRUCT_H_ */
  </code></pre>
  <p>EDIT: the error message itself:</p>
  <pre><code>Invoking: Cygwin C++ Linker
  g++  -o &quot;HelloCPP.exe&quot; ./src/AttenuationConfigurationTable.o ./src/Hello2.o ./src/HelloCPP.o   
  /usr/lib/gcc/x86_64-pc-cygwin/10/../../../../x86_64-pc-cygwin/bin/ld: ./src/HelloCPP.o:/cygdrive/c/Users/ralph/files/programming/workspaces/HelloCPP/HelloCPP/Debug/../src/HelloCPP.cpp:15: undefined reference to `AttenuationConfigurationTable::load_attenuation_calibration_table_from_flash(flash_entry_struct*)'
  collect2: error: ld returned 1 exit status
  make: *** [makefile:58: HelloCPP.exe] Error 1
  &quot;make all&quot; terminated with exit code 2. Build might be incomplete.
  </code></pre>