Click here to Skip to main content
15,943,757 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
I am trying to make a global 2D array using vectors, but I am having some trouble in doing so. Below code is a small part of my project where I need to make a global 2D array whose size has to be passed through a command line. I am passing row and column as command line arguments.

"ESSolver.h"
#include <vector>

using namespace std;

extern int row;
extern int col;

extern vector<vector<double>> _muPop(row, vector<double>(col));

class ESSolver
{
	public:
		ESSolver();	
		void Init();
		void Disp();

	private:
		vector< vector<double> > *muPop;
};


"ESSolver.cpp"
#include <iostream>
#include <vector>
#include "../include/ESSolver.h"

using namespace std;

ESSolver::ESSolver()
{
	muPop = &_muPop;
	
	return;
}

void ESSolver::Init()
{
	// Initializing object variable
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			(*muPop)[i][j] = i+1;
		}
	}
}

void ESSolver::Disp()
{
	// Initializing object variable
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			cout << (*muPop)[i][j] << " ";
		}
		cout << endl;
	}
}


"main.cpp"
#include "../include/ESSolver.h"
#include <vector>
#include <iostream>

using namespace std;

int row;
int col;

vector<vector<double>> _muPop(row, vector<double>(col));

int main(int argc, char *argv[]){
	//./main #row #col
	
	row = atoi(argv[1]);
	col = atoi(argv[2]);
	
	ESSolver es;
	es.Init();
}


modified 29-Jan-21 21:01pm.

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 
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 
QuestionHow to pass size of an array from command line Pin
User 135094506-Dec-17 18:09
professionalUser 135094506-Dec-17 18:09 
AnswerRe: How to pass size of an array from command line Pin
Rick York6-Dec-17 18:52
mveRick York6-Dec-17 18:52 
GeneralRe: How to pass size of an array from command line Pin
User 135094506-Dec-17 20:07
professionalUser 135094506-Dec-17 20:07 
GeneralRe: How to pass size of an array from command line Pin
Rick York6-Dec-17 20:31
mveRick York6-Dec-17 20:31 
GeneralRe: How to pass size of an array from command line Pin
User 135094506-Dec-17 20:32
professionalUser 135094506-Dec-17 20:32 
GeneralRe: How to pass size of an array from command line Pin
CPallini7-Dec-17 3:19
mveCPallini7-Dec-17 3:19 
QuestionCEdit::LineLength returning zero Pin
ForNow6-Dec-17 13:16
ForNow6-Dec-17 13:16 
AnswerRe: CEdit::LineLength returning zero Pin
Rick York6-Dec-17 14:41
mveRick York6-Dec-17 14:41 
GeneralRe: CEdit::LineLength returning zero Pin
ForNow6-Dec-17 15:51
ForNow6-Dec-17 15:51 
GeneralRe: CEdit::LineLength returning zero Pin
Rick York6-Dec-17 19:00
mveRick York6-Dec-17 19:00 

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.