Click here to Skip to main content
15,900,906 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: current user Pin
David Crow12-Dec-17 15:42
David Crow12-Dec-17 15:42 
Questionunsigned and signed in C Pin
Anonygeeker11-Dec-17 18:45
Anonygeeker11-Dec-17 18:45 
AnswerRe: unsigned and signed in C Pin
Shaurya Sinha11-Dec-17 19:23
professionalShaurya Sinha11-Dec-17 19:23 
GeneralRe: unsigned and signed in C Pin
Anonygeeker11-Dec-17 20:01
Anonygeeker11-Dec-17 20:01 
GeneralRe: unsigned and signed in C Pin
Shaurya Sinha11-Dec-17 20:05
professionalShaurya Sinha11-Dec-17 20:05 
GeneralRe: unsigned and signed in C Pin
Rick York12-Dec-17 4:45
mveRick York12-Dec-17 4:45 
GeneralRe: unsigned and signed in C Pin
David Crow12-Dec-17 15:44
David Crow12-Dec-17 15:44 
QuestionWriting a Sorting Algorithm -- NEED HELP! Pin
Member 135671429-Dec-17 11:36
Member 135671429-Dec-17 11:36 
GeneralRe: Writing a Sorting Algorithm -- NEED HELP! Pin
PIEBALDconsult9-Dec-17 11:37
mvePIEBALDconsult9-Dec-17 11:37 
GeneralRe: Writing a Sorting Algorithm -- NEED HELP! Pin
Member 135671429-Dec-17 12:01
Member 135671429-Dec-17 12:01 
GeneralRe: Writing a Sorting Algorithm -- NEED HELP! Pin
Richard MacCutchan9-Dec-17 21:52
mveRichard MacCutchan9-Dec-17 21:52 
SuggestionRe: Writing a Sorting Algorithm -- NEED HELP! Pin
David Crow10-Dec-17 14:31
David Crow10-Dec-17 14:31 
Questionlocal pointer need to initialize or not? Pin
samzcs8-Dec-17 8:04
samzcs8-Dec-17 8:04 
AnswerRe: local pointer need to initialize or not? Pin
jschell8-Dec-17 8:43
jschell8-Dec-17 8:43 
GeneralRe: local pointer need to initialize or not? Pin
samzcs8-Dec-17 16:15
samzcs8-Dec-17 16:15 
GeneralRe: local pointer need to initialize or not? Pin
jschell11-Dec-17 7:03
jschell11-Dec-17 7:03 
AnswerRe: local pointer need to initialize or not? Pin
CPallini8-Dec-17 11:20
mveCPallini8-Dec-17 11:20 
QuestionHow to make global 2D array using vectors Pin
User 135094507-Dec-17 23:14
professionalUser 135094507-Dec-17 23:14 
AnswerRe: How to make global 2D array using vectors Pin
Richard MacCutchan8-Dec-17 0:04
mveRichard MacCutchan8-Dec-17 0:04 
AnswerRe: How to make global 2D array using vectors Pin
Jochen Arndt8-Dec-17 0:05
professionalJochen Arndt8-Dec-17 0:05 
AnswerRe: How to make global 2D array using vectors Pin
CPallini8-Dec-17 6:14
mveCPallini8-Dec-17 6:14 
As suggested, don't use globals. Try, for instance
C++
#include <vector>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

class Matrix
{
  int R, C;
  vector <vector <int> > m;
public:
  Matrix(int r, int c):R(r),C(c)
  {
    for (int r = 0; r<R; ++r)
    {
      m.push_back(vector <int >());
      for (int c = 0; c<C; ++c)
        m[r].push_back(c+1);
    }
  }
  friend ostream & operator << (ostream & os, const Matrix & mat);
};


ostream & operator << (ostream & os, const Matrix & mat)
{
  for (int r = 0; r<mat.R; ++r)
  {
    for (int c = 0; c<mat.C; ++c)
      os << setw(4) << mat.m[r][c];
    os << endl;
  }
  return os;
}

int main(int argc, char * argv[])
{
  int rows=1, cols=1;

  if ( argc >= 3)
  {
    rows = stoi(argv[1]);
    cols = stoi(argv[2]);
  }

  Matrix m(rows,cols);
  cout << m << endl;
}

GeneralRe: How to make global 2D array using vectors Pin
User 1350945013-Dec-17 7:46
professionalUser 1350945013-Dec-17 7:46 
GeneralRe: How to make global 2D array using vectors Pin
CPallini13-Dec-17 8:11
mveCPallini13-Dec-17 8:11 
QuestionSystem tray Pin
justin12046-Dec-17 22:51
justin12046-Dec-17 22:51 
SuggestionRe: System tray Pin
Jochen Arndt6-Dec-17 23:15
professionalJochen Arndt6-Dec-17 23:15 

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.