Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing maps with different value types to a function in C++
    primarykey
    data
    text
    <p>I am having to add new functionality to some old, poorly written code. There are 50 different lists which need to be displayed and processed on screens, and the current code for them is all cut-and-paste with minor modifications from 2 different types, one a list in a DAO database and the other in a map.</p> <p>I wrote a Search class which provides the functionality, and a helper class for each of the list types to provide the basic functions needed by Search. The map helper class only requires access to the tstring Key, it does not need the differentObject Values. But, I can't get this to compile.</p> <p>Since the various differentObjects have no relationship, I defined a class SearchValue which is basically empty, and added it in the .h as a superclass for all the differentObject classes.</p> <p>As an example, here is one of the map definitions:</p> <pre><code>typedef map&lt;tstring, MyPatListEntry *, tstringcomp&gt; patlist; </code></pre> <p>MyPatListEntry is defined:</p> <pre><code>class MyPatListEntry : public SearchValue { </code></pre> <p>and I have the function defined as:</p> <pre><code>ListHelper(map&lt;tstring, SearchValue *&gt; *map, CString fieldName) </code></pre> <p>The compiler (VC++) gives the error that none of the definitions for ListHelper() handles all the arguments. If I replace SearchValue with MyPatListEntry in the definition the compilation works, so the basic format is correct. </p> <p>I've looked around on the site and found people suggesting this type of thing be done with function templates, and I suppose that would work, but I am curious whether there is some reason doing it this way does not work.</p> <p>Thanks for any thoughts.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload