User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 374,021 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,765 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 693 | Replies: 3
Reply
Join Date: Mar 2005
Posts: 90
Reputation: tyczj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
tyczj tyczj is offline Offline
Junior Poster in Training

error help

  #1  
Feb 7th, 2006
cant figure out this error. im trying to do a 3 dimensional static array that just displays the number in a matrix form

ex: 1111111
1111111
1111111

im sure the error has somethin to do with the depth, row and col being constants but i dont knwo how to fix it cause that how its suppose to be

: error C2440: 'initializing' : cannot convert from 'const int' to 'struct Node [6][8][4]'
There are no conversions to array types, although there are conversions to references or pointers to arrays

Space:pace()
{
int number = 0;
error Node array[DEPTH][ROW][COL] = NULL;

};


#include <iostream>
#include <string>

using namespace std;


struct Node
{
	int number;
	bool open;
	char color;
};


class Space {

	private:
	#define DEPTH 6
	#define ROW 8
	#define COL 4

	Node array[DEPTH][ROW][COL];

	public:

	Space();
	~Space();
	Space(const Space& space);
	Space& operator= (Space&(const Space& space));
	void setAllNodes();
	void print();
	

};


void main()
{

	

};

void Space::setAllNodes()
{
	for(int d=0; d<DEPTH; d++)
		for(int j=0; j<ROW; j++)
			for(int k=0; k<COL; k++)
			{
			   array[d][j][k].open = true;
			   array[d][j][k].color = 'j';
			   array[d][j][k].number = d;
			}
};

void Space::print()
{
	int k = 0;
	for(int i=0; i<DEPTH; i++) {
		for(int j=0; j<ROW; j++) {
			for(int k=0; k<COL; k++)
			{ 
				cout << array[i][j][k].number << ' ';
			}
				cout << endl;
		}

	}
	cout << endl;

}


Space::Space() 
{ 
	int number = 0;
   error     Node array[DEPTH][ROW][COL] = NULL;

};

Space::~Space() { }

Space::Space(const Space& space) 
{ 
	
	
};

Space&  Space::operator= (Space&(const Space& space)) 
{ 
	

	return *this;
};
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2005
Location: Tokyo, Japan
Posts: 1,480
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Rep Power: 8
Solved Threads: 98
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: error help

  #2  
Feb 7th, 2006
Try only this
Node array[DEPTH][ROW][COL];
Reply With Quote  
Join Date: Mar 2005
Posts: 90
Reputation: tyczj is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
tyczj tyczj is offline Offline
Junior Poster in Training

Re: error help

  #3  
Feb 7th, 2006
it gives me a warning but it runs now atleast thx
Reply With Quote  
Join Date: Nov 2005
Location: Canada
Posts: 226
Reputation: dwks will become famous soon enough dwks will become famous soon enough 
Rep Power: 4
Solved Threads: 18
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: error help

  #4  
Feb 9th, 2006
Try this:
Node array[DEPTH][ROW][COL] = {{{NULL}}};
That should get rid of your error and your warning.
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 11:16 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC