LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-26-2006, 09:31 PM   #1
lucky6969b
Member
 
Registered: Nov 2005
Posts: 337

Rep: Reputation: 30
const/static members in classes


I couldn't declare a class like this
class a
{
public:
const float[4] anArray = { 1.1f, 2.2f, 3.3f, 4.4f };
};

I don't see why there is a problem.
A class cannot contain constants?
Any comments are welcome
Thanks
Jack
 
Old 03-26-2006, 09:50 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,376

Rep: Reputation: 147Reputation: 147
try initialising the constant in the constructor.

or make them static const and initialise them as you would other static member variables.
 
Old 03-27-2006, 05:43 PM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
'[4]' needs to be after 'anArray'.
ta0kira
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Non-Const reference? ChemicalBurn Programming 4 04-05-2005 08:32 AM
OOP (PHP) classes and extended classes ldp Programming 3 03-05-2005 11:45 AM
const in C++ lazyboy0001 Programming 5 04-08-2004 04:43 PM
Saving an Ip to a Const? Half_Elf Linux - Networking 3 07-12-2002 08:20 PM
why compiler gives undefined references on static members??? Hano Programming 8 06-26-2002 11:12 AM


All times are GMT -5. The time now is 01:40 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration