Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ rookie: how can I store code for a class in helper/auxiliary files, but still access all class member functions?
    primarykey
    data
    text
    <p>I have written a class that reads in data from external files, manipulates the data, and then does a calculation. </p> <p>The class is very long, particularly the constructor. This is where I read in data from external files and manipulate it in preparation for the calculation. I use template functions to do this.</p> <p>I know that it would be better style to split the class up, but I am using it in combination with commercial code that I can't change. Also, people who will need to use the code need it to be one class + auxiliary files, so I'm restricted to this one class. To make the code more readable, I would like to store some of the code from the constructor in helper .cpp/.h files called "auxiliary.h/.cpp" and access it through functions. </p> <p>Here's the problem: </p> <p>1) Passing the template functions (member functions of the class) as function arguments to the auxiliary files. I can't do this, although I have heard it might be possible through something called "disambiguation." It is no problem to pass non-template functions and vectors and things like that... The template functions are the problem. </p> <p>2) Also, even if I could pass the template functions as arguments to the functions that access the auxiliary files, my argument lists end up very long.</p> <p>What I would like to know is, is there some way to make the auxiliary files "see" the class? I tried passing an INSTANCE of the class as an argument/parameter in each function that does stuff in the auxiliary files. But this results in "instanceName not declared in this scope" and it does seem like a rather circular/convoluted approach. </p> <p>Any advice would be very appreciated. Thanks.</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.
    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