Gao Lei wrote:
Hi, guys,

I have a question during my developing,

In Java it is very easy to assign different final value sto different
instances of an object, but when in C ++, it is difficult, especially
for an array. Like following,

class CPPCls
{
    const int iarray[10];
    .......
}

How to initialize this const array within C++?

Thanks in advance.
Gao Lei.


Well, if you are interested in initializing a const array with C++, you should consider somehting like
const int array[] = {
    0,
    1,
    // ....
    9
};

I suggest that you leave out of a member fuinction declaration (ie make it global , although it doesn't sound cool!) since the usual C++ compilers complain about it!

I hope this would help.
Dimitrios

-- 
============================================================================
                         Dimitrios Vyzovitis
                  Information Processing Laboratory
                 Aristotle University of Thessaloniki
           [EMAIL PROTECTED] or [EMAIL PROTECTED]
                    http://egnatia.ee.auth.gr/~dviz
 
begin:          vcard
fn:             Dimitrios Vyzovitis
n:              Vyzovitis;Dimitrios
org:            AUTH
adr:            142 V. Olgas Avenue;;;Thessaloniki;;54645;Greece
email;internet: [EMAIL PROTECTED]
tel;work:       ++30-31-996359
tel;home:       ++30-31-817780
note:           Orientation in space and time is the framework of cognition.
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard

Reply via email to