Thread: C++ Arrays
View Single Post
Old 11-09-2006, 02:47 PM   #11 (permalink)
milt
Forum Expert
 
milt's Avatar
 
Join Date: Nov 2003
Location: Lancaster, PA
Age: 20
Posts: 1,606
Send a message via AIM to milt Send a message via Yahoo to milt Send a message via Skype™ to milt
Default

Code:
class Calendar
{
public:
	int year;
	int month;
	Month *months;

	Calendar()
	{
		Month table[] =
		{
			Month("January", 31),
			Month("February", 28),
			Month("March", 31),
			Month("April", 30),
			Month("May", 31),
			Month("June", 30),
			Month("July", 31),
			Month("August", 31),
			Month("September", 30),
			Month("October", 31),
			Month("November", 30),
			Month("December", 31)
		};

		months = &table; //Line of error
	}

	~Calendar()
	{
		delete [] months;
	}
}
c:\Documents and Settings\JoshuaT\My Documents\Visual Studio Projects\Calendar\Calendar.cpp(52): error C2440: '=' : cannot convert from 'Month (*__w64 )[12]' to 'Month *'

I wanted to try it this way, but for some reason I keep getting that error. Shouldn't it technically work?
__________________
--Milt, AKA Pokey
milt is offline   Reply With Quote