delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/31/19:40:49

Message-ID: <3390B540.64B66576@abc.se>
Date: Sun, 01 Jun 1997 01:33:20 +0200
From: Henrik Baarnhielm <Henrik DOT Baarnhielm AT abc DOT se>
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com
Subject: Arrays and Class members, Help!

I am making a class which has some class members declared with const.
They are initialized directly in the class declaration. I thought this
couldn't be done, but it worked until I tried to use arrays. Some of the
constant variables declared in the class are arrays, both single- and
multidimensional. I can initialize them and the compiler doesn't say
anything, but when I try to use them the LINKER starts complain, and
says there's an undefined reference. I don't understand, could somebody
help?

Example

class foo
{
	private:
		foo();
		void test();
	private:
		const short foovar=200; // <- This works
		const short footest[13]={0,1,2,3,4,5,6,7,8,9,10,11,12}; // <- This
doesn't work 
		const short dummyfoo[2][9]={{0,1,2,3,4,5,6,7,8},
					    {0,1,2,3,4,5,6,7,8}}; // <- This doesn't work
};

Please help me!

Thanks

-- 
***************************************
Internet : Henrik DOT Baarnhielm AT abc DOT se
Fidonet  : Henrik Baarnhielm, 2:201/235
***************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019