Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

Rep: Reputation: 30
const/static members in classes

I couldn't declare a class like this
class a
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
Old 03-26-2006, 09:50 PM   #2
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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
Senior Member
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

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


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 06:31 PM.

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