Click here to Skip to main content
15,890,123 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralTemplate class Pin
JohnZZ18-Jun-05 7:03
JohnZZ18-Jun-05 7:03 
GeneralRe: Template class Pin
S. Senthil Kumar18-Jun-05 7:40
S. Senthil Kumar18-Jun-05 7:40 
GeneralRe: Template class Pin
JohnZZ18-Jun-05 8:02
JohnZZ18-Jun-05 8:02 
GeneralRe: Template class Pin
John M. Drescher18-Jun-05 8:23
John M. Drescher18-Jun-05 8:23 
GeneralRe: Template class Pin
JohnZZ18-Jun-05 14:25
JohnZZ18-Jun-05 14:25 
GeneralRe: Template class Pin
John M. Drescher18-Jun-05 16:17
John M. Drescher18-Jun-05 16:17 
GeneralRe: Template class Pin
JohnZZ18-Jun-05 23:56
JohnZZ18-Jun-05 23:56 
GeneralRe: Template class Pin
John R. Shaw19-Jun-05 14:43
John R. Shaw19-Jun-05 14:43 
I do not have a solution but I have a suggestion. Use a vector as a class member to actualy hold the data (a lot of work went into make it efficient).

// Minor example
template<clas T> // T can be almost any type
class my_class
{
public:
    typedef std::vector<T> array_type;
    void resize(int d1,int d2)
    {
        unsigned new_size = abs(d1) + abs(d1);
        // It must be an odd number so that we
        // can have a center index value from which
        // to offset from.
        if( !(new_size & 1) )
            ++new_size;
        data_array.resize(new_size);
        center_index = new_size>>1;
    }
    const T& get_at(int index) // operator[] would call this
    {
        unsigned new_index = center_index + index;
        // This is probably not need, because
        // the vector class will probably throw an error.
        if( new_index >= data_array.size() )
            throw(range_error );
        data_array[new_index];
    }
protected:
    // Single dimension array
    array_type data_array;
    unsigned center_index.
};


The above has a long way to go before it meets your requirements, but it is a good place to begin.

Oh; by the way, the following will not work and will generate errors:

lowIndex = newLowIndex; // not know at runtime
highIndex = newHighIndex; // not know at runtime
double data[highIndex-lowIndex]; // therefor, this is an error


INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
GeneralSetFocus function Pin
volovik18-Jun-05 6:14
volovik18-Jun-05 6:14 
GeneralRe: SetFocus function Pin
John M. Drescher18-Jun-05 11:03
John M. Drescher18-Jun-05 11:03 
GeneralRe: SetFocus function Pin
PJ Arends18-Jun-05 11:33
professionalPJ Arends18-Jun-05 11:33 
GeneralRe: SetFocus function Pin
Toby Opferman18-Jun-05 13:53
Toby Opferman18-Jun-05 13:53 
GeneralRe: SetFocus function Pin
John M. Drescher18-Jun-05 16:19
John M. Drescher18-Jun-05 16:19 
GeneralRe: SetFocus function Pin
Toby Opferman18-Jun-05 19:42
Toby Opferman18-Jun-05 19:42 
Questionwhat are external dependencies? Pin
sayup18-Jun-05 2:52
sayup18-Jun-05 2:52 
AnswerRe: what are external dependencies? Pin
Saurabh.Garg18-Jun-05 15:00
Saurabh.Garg18-Jun-05 15:00 
GeneralRe: what are external dependencies? Pin
sayup23-Jun-05 19:31
sayup23-Jun-05 19:31 
AnswerRe: what are external dependencies? Pin
Nilesh K.19-Jun-05 18:23
Nilesh K.19-Jun-05 18:23 
GeneralDialog box open issue. Please HELP! Pin
volovik18-Jun-05 2:37
volovik18-Jun-05 2:37 
GeneralRe: Dialog box open issue. Please HELP! Pin
Gary R. Wheeler18-Jun-05 4:27
Gary R. Wheeler18-Jun-05 4:27 
GeneralRe: Dialog box open issue. Please HELP! Pin
volovik18-Jun-05 6:07
volovik18-Jun-05 6:07 
GeneralRe: Dialog box open issue. Please HELP! Pin
Gary R. Wheeler18-Jun-05 8:08
Gary R. Wheeler18-Jun-05 8:08 
Generalwant menu window without the border Pin
LiYS18-Jun-05 2:22
LiYS18-Jun-05 2:22 
GeneralWLAN Card RSSI Pin
Member 204556018-Jun-05 1:37
Member 204556018-Jun-05 1:37 
QuestionHow set message handling right? Pin
ryuki18-Jun-05 1:17
ryuki18-Jun-05 1:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.