Click here to Skip to main content
14,114,975 members

C / C++ / MFC

 
GeneralRe: Preprocessor Directives in C Program Pin
k505423-Apr-19 7:01
memberk505423-Apr-19 7:01 
GeneralRe: Preprocessor Directives in C Program Pin
leon de boer23-Apr-19 7:15
memberleon de boer23-Apr-19 7:15 
JokeRe: Preprocessor Directives in C Program Pin
Peter_in_278023-Apr-19 12:15
professionalPeter_in_278023-Apr-19 12:15 
GeneralRe: Preprocessor Directives in C Program Pin
leon de boer23-Apr-19 14:43
memberleon de boer23-Apr-19 14:43 
GeneralRe: Preprocessor Directives in C Program Pin
Richard MacCutchan23-Apr-19 21:14
protectorRichard MacCutchan23-Apr-19 21:14 
QuestionThe GOD Pin
hbtalha21-Apr-19 7:30
memberhbtalha21-Apr-19 7:30 
AnswerRe: The GOD Pin
Gerry Schmitz21-Apr-19 7:51
mveGerry Schmitz21-Apr-19 7:51 
QuestionVector of Class with Array Pin
T Bones Jones19-Apr-19 10:21
memberT Bones Jones19-Apr-19 10:21 
I have a class Matrix that I made years ago and has worked without problems. It looks like this:

class Matrix
 {
  private:
    double *M;
    int ROWS, COLUMNS;
  public:
    Matrix (): M(new double[1]), ROWS(1), COLUMNS(1) { }                        // default constructor
    Matrix (int R, int 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 (int i=0; i<(ROWS*COLUMNS); i++) M[i]=m.M[i]; }

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


In my new program, I have made use of a vector of this Matrix class, as in
vector<matrix> J;

The problem comes when I add a new Matrix to this vector, as in:
J.push_back(NewMatrix);

The program will run fine 10 or 20 times, but then crash at this line with J.push_back().

I have tried using the vector like a conventional array, where I know the size, and use a for loop, in the form: for (unsigned i=0; i
AnswerRe: Vector of Class with Array Pin
CPallini19-Apr-19 10:32
mveCPallini19-Apr-19 10:32 
GeneralRe: Vector of Class with Array Pin
T Bones Jones19-Apr-19 11:04
memberT Bones Jones19-Apr-19 11:04 
GeneralRe: Vector of Class with Array Pin
Richard MacCutchan19-Apr-19 21:53
protectorRichard MacCutchan19-Apr-19 21:53 
GeneralRe: Vector of Class with Array Pin
CPallini20-Apr-19 4:17
mveCPallini20-Apr-19 4:17 
GeneralRe: Vector of Class with Array Pin
T Bones Jones20-Apr-19 6:31
memberT Bones Jones20-Apr-19 6:31 
GeneralRe: Vector of Class with Array Pin
CPallini20-Apr-19 7:18
mveCPallini20-Apr-19 7:18 
GeneralRe: Vector of Class with Array Pin
Richard MacCutchan20-Apr-19 22:12
protectorRichard MacCutchan20-Apr-19 22:12 
GeneralRe: Vector of Class with Array Pin
T Bones Jones22-Apr-19 4:52
memberT Bones Jones22-Apr-19 4:52 
GeneralRe: Vector of Class with Array Pin
Richard MacCutchan22-Apr-19 5:52
protectorRichard MacCutchan22-Apr-19 5:52 
GeneralRe: Vector of Class with Array Pin
Gerry Schmitz22-Apr-19 8:54
mveGerry Schmitz22-Apr-19 8:54 
QuestionConcept of namespace Pin
Aakashdata16-Apr-19 21:14
memberAakashdata16-Apr-19 21:14 
AnswerRe: Concept of namespace Pin
Richard MacCutchan16-Apr-19 22:19
protectorRichard MacCutchan16-Apr-19 22:19 
AnswerRe: Concept of namespace Pin
CPallini17-Apr-19 2:06
mveCPallini17-Apr-19 2:06 
AnswerRe: Concept of namespace Pin
harshalipatel17-Apr-19 2:19
memberharshalipatel17-Apr-19 2:19 
GeneralRe: Concept of namespace Pin
leon de boer20-Apr-19 0:11
memberleon de boer20-Apr-19 0:11 
GeneralRe: Concept of namespace Pin
Richard MacCutchan20-Apr-19 1:32
protectorRichard MacCutchan20-Apr-19 1:32 
GeneralRe: Concept of namespace Pin
jschell21-Apr-19 7:33
memberjschell21-Apr-19 7:33 

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.


Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190518.1 | Last Updated 20 May 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid