Click here to Skip to main content
15,357,240 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionvector and Template confusion Pin
T Bones Jones23-May-22 7:33
MemberT Bones Jones23-May-22 7:33 
AnswerRe: vector and Template confusion Pin
Victor Nijegorodov23-May-22 8:09
MemberVictor Nijegorodov23-May-22 8:09 
GeneralRe: vector and Template confusion Pin
T Bones Jones23-May-22 8:12
MemberT Bones Jones23-May-22 8:12 
AnswerRe: vector and Template confusion Pin
CPallini23-May-22 22:02
mveCPallini23-May-22 22:02 
GeneralRe: vector and Template confusion Pin
T Bones Jones24-May-22 4:24
MemberT Bones Jones24-May-22 4:24 
GeneralRe: vector and Template confusion Pin
CPallini24-May-22 20:02
mveCPallini24-May-22 20:02 
AnswerRe: vector and Template confusion Pin
Richard MacCutchan23-May-22 22:03
mveRichard MacCutchan23-May-22 22:03 
GeneralRe: vector and Template confusion Pin
T Bones Jones24-May-22 4:33
MemberT Bones Jones24-May-22 4:33 
Here is my struct and the NewLandmarks vector. Do you see anything in this code that could be causing this problem?

struct landmarktype {
    std::string fiducial{};
    std::string name{};
    Matrix location{}; //=Initialize(3,1);
    std::vector <size_t> subtractions{};
};

vector <landmarktype> NewLandmarks;


declared earlier in the code, but in case it's important here is my Matrix class:

class Matrix {
    private:
        double * M;
        size_t ROWS, COLUMNS;
    public:
        Matrix(): M(NEW double[1]), ROWS(1), COLUMNS(1) {} // default constructor
        Matrix(size_t R, size_t C): M(NEW double[R * C]), ROWS(R), COLUMNS(C) {} // constructor
        ~Matrix() {delete[] M;}; // destructor
        Matrix(const Matrix & m): M(NEW double[m.ROWS * m.COLUMNS]), // copy constructor
            ROWS(m.ROWS), COLUMNS(m.COLUMNS) {
            for (size_t i = 0; i != (ROWS * COLUMNS); i++) M[i] = m.M[i];
            }

    double & operator()(const size_t R,
        const size_t C); //output a value from (row,col) cell
    double operator()(const size_t R,
        const size_t C) const;

    [[nodiscard]] size_t rows() const { return ROWS; }
    [[nodiscard]] size_t cols() const { return COLUMNS; }

    void set(const size_t R, const size_t C) {
        double* newMat = NEW double[R*C];
        delete[] M;
        M = newMat;
        ROWS = R;
        COLUMNS = C;
    }

    void clear()
    {
        double* newMat = DBG_NEW double[0];
        delete[] M;
        M = newMat;
        ROWS = 0;
        COLUMNS = 0;
    }

    void print(std::fstream & ) const;
}


void Matrix::print(fstream & fout) const {
    size_t r, c;
    for (c = 0; c != COLUMNS; ++c)
        for (r = 0; r != ROWS; ++r)
        {
            fout << setiosflags(ios::fixed) << std::setprecision(outputprecision) << std::setw(22) << M[r * COLUMNS + c];
            if ((r*COLUMNS+c) != (ROWS*COLUMNS - 1)) fout << ", ";
        }
}

GeneralRe: vector and Template confusion Pin
Richard MacCutchan24-May-22 5:02
mveRichard MacCutchan24-May-22 5:02 
GeneralRe: vector and Template confusion Pin
T Bones Jones24-May-22 5:08
MemberT Bones Jones24-May-22 5:08 
GeneralRe: vector and Template confusion Pin
Richard MacCutchan24-May-22 5:11
mveRichard MacCutchan24-May-22 5:11 
QuestionApplication check for virus Pin
Gopi Nath23-May-22 1:18
MemberGopi Nath23-May-22 1:18 
AnswerRe: Application check for virus Pin
Richard MacCutchan23-May-22 1:25
mveRichard MacCutchan23-May-22 1:25 
AnswerRe: Application check for virus Pin
Dave Kreskowiak23-May-22 2:16
mveDave Kreskowiak23-May-22 2:16 
AnswerRe: Application check for virus Pin
Gopi Nath23-May-22 18:30
MemberGopi Nath23-May-22 18:30 
QuestionSetting Font and Text Colors items of ComboBox Pin
ForNow22-May-22 12:32
MemberForNow22-May-22 12:32 
AnswerRe: Setting Font and Text Colors items of ComboBox Solved almost Pin
ForNow22-May-22 13:28
MemberForNow22-May-22 13:28 
GeneralRe: Setting Font and Text Colors items of ComboBox Solved almost Pin
Victor Nijegorodov22-May-22 20:14
MemberVictor Nijegorodov22-May-22 20:14 
GeneralRe: Setting Font and Text Colors items of ComboBox Solved almost Pin
ForNow22-May-22 22:26
MemberForNow22-May-22 22:26 
QuestionAccessing and displaying semaphore count Pin
coco24322-May-22 1:42
Membercoco24322-May-22 1:42 
AnswerRe: Accessing and displaying semaphore count Pin
Mircea Neacsu22-May-22 2:02
mvaMircea Neacsu22-May-22 2:02 
GeneralRe: Accessing and displaying semaphore count Pin
coco24322-May-22 2:48
Membercoco24322-May-22 2:48 
GeneralRe: Accessing and displaying semaphore count Pin
Mircea Neacsu22-May-22 2:51
mvaMircea Neacsu22-May-22 2:51 
GeneralRe: Accessing and displaying semaphore count Pin
Richard Andrew x6422-May-22 3:04
professionalRichard Andrew x6422-May-22 3:04 
GeneralRe: Accessing and displaying semaphore count Pin
coco24322-May-22 5:07
Membercoco24322-May-22 5:07 

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.