im trying to make a table using askii art thats changed when the dimensions of the array are changed. i have been playin it for like 2 hours and i cant figure it out, here is was i have so far.

my definitions

#define M char (197);
#define U_L char (218);
#define L_L char (192);
#define U_R char (191);
#define L_R char (217);
#define T_M char (194);
#define L_MT char (193);
#define VERT_LINE char (179);
#define VISIT char (219);
#define LINE  char (196);
#define ACTIVE char (248);

code

My print function so u dont have to search for it

void Darray::print () const
{
	// makes inside of grid
	for(int d=0; d<DEPTH; d++)
	{
				cout << LINE;
				cout << L_MT;
				cout << LINE;
				cout << L_MT;
				cout << LINE;
				cout << endl;
		for(int r=0; r<ROW; r++)
		{
			
				cout << LINE;
			cout << M;
			cout << LINE;
			cout << M;
			cout << LINE;
			cout << endl;
			for(int c=0; c<COL; c++)
			{

				cout << LINE;
				cout << T_M;
				cout << LINE;
				cout << T_M;
				cout << LINE;
				cout << endl;


			
			}


			
		
		}
		
	
	cout << endl;
	}

}

full code:

#include <iostream>
#include <conio.h>
#include "Definitions.h"
using namespace std;


class Darray{
protected:
		int DEPTH,
			  ROW,
			  COL;
		int*** array;

public:
	
	Darray();
	Darray(int depth, int row, int col);
	~Darray();
	Darray(const Darray& darray);						//copy constructor
	Darray& Darray::operator= (const Darray& darray);	//assignment operator

	void getDimensions(int DEPTH, int ROW, int COL);
	void destroy();
	void create();
	void init();
	void resetSize(int depth, int row, int col);

	void print () const;
};

Darray::Darray()
{
	DEPTH=0;
	ROW=0;
	COL=0;
	array=NULL;
}

void Darray::create()
{
	array = new int** [DEPTH];
	for(int d=0; d<DEPTH; d++) {
		*(array+d) = new int* [ROW];
		for (int r=0; r<ROW; r++)
			*(*(array+d)+r) = new int [COL];
	}
}

Darray::Darray(int depth, int row, int col)
{
	DEPTH = depth;
	ROW = row;
	COL = col;
	create();
	init();

}

Darray::~Darray()
{
	destroy();
}

Darray::Darray(const Darray& darray)
{
	DEPTH = darray.DEPTH;
	ROW = darray.ROW;
	COL = darray.COL;
	create();

	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = darray.array[d][r][c];
}

Darray& Darray::operator= (const Darray& darray)
{
	resetSize(darray.DEPTH, darray.ROW, darray.COL);

	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = darray.array[d][r][c];
			
			return *this;	
}

void Darray::destroy()
{
	 for (int d=0; d<DEPTH; d++)
	 {
		 for(int r=0; r<ROW; r++)
			 delete [] *(*(array+d)+r);
		 delete [] *(array+d);
	 }
	 delete [] array;
 }

void Darray::print () const
{
	// makes inside of grid
	for(int d=0; d<DEPTH; d++)
	{
				cout << LINE;
				cout << L_MT;
				cout << LINE;
				cout << L_MT;
				cout << LINE;
				cout << endl;
		for(int r=0; r<ROW; r++)
		{
			
				cout << LINE;
			cout << M;
			cout << LINE;
			cout << M;
			cout << LINE;
			cout << endl;
			for(int c=0; c<COL; c++)
			{

				cout << LINE;
				cout << T_M;
				cout << LINE;
				cout << T_M;
				cout << LINE;
				cout << endl;


			
			}


			
		
		}
		
	
	cout << endl;
	}

}
void Darray::init()
{
	for(int d=0; d<DEPTH; d++)
		for(int r=0; r<ROW; r++)
			for(int c=0; c<COL; c++)
				array[d][r][c] = 0;
}

void Darray::getDimensions(int DEPTH, int ROW, int COL)
{
	cout << "Enter the grid dimensions: " << endl;
	cin >> DEPTH >> ROW >> COL;

	cout << "The Depth is: " << DEPTH << "  The Row is: " << ROW
		<< "  The Columns is: " << COL << endl;
}

void Darray::resetSize(int depth, int row, int col)
{
	destroy();
	DEPTH=depth;
	ROW=row;
	COL=col;
	create();
	init();
}

it needs spaces in the boxes cause there is goin to be stuff in them.
______________
similar to a martix| | | | | |
----------------

thats the best example i could give on what its suppose to look like just a bunch of boxes with expty spaces in the middle for a number.

my output is all jumbled up

so i got it to print how i want it to but i cant get it to show the right numer of rows and columns.

void Darray::print () const
{
	
	// makes inside of grid
	for(int d=0; d<DEPTH; d++)		
		for(int r=0; r<ROW; r++)			
				for(int c=0; c<COL; c++)
				{
				cout << LINE;
				cout << T_M;
				cout << LINE;
				cout << T_M;
				cout << LINE;
				cout << endl;
							
							
				cout << endl;

				cout << LINE;
				cout << M;
				cout << LINE;
				cout << M;
				cout << LINE;

				cout << endl;
							
							
				cout << endl;

				cout << LINE;
				cout << L_MT;
				cout << LINE;
				cout << L_MT;
				cout << LINE;

				cout << endl;
				
				
				cout << endl;
				}
			
	
	cout << endl;
	

}

when ever i change the dimensions in the main to test it, it just adds everything to the depth and no rows or columns get added ex. i have it set to (2,3,4) and the depth is 9 so it gets printed 9 times instead of 2 like i want it too

please help me i cant figure it out

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.