linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: wwp <subscript@free.fr>
To: Luciano Moreira - igLnx <lucianolnx@ig.com.br>
Cc: linux-c-programming@vger.kernel.org
Subject: Re: "static const" attribute in C++ (How to ?)
Date: Fri, 2 Jul 2004 09:47:55 +0200	[thread overview]
Message-ID: <20040702094755.73ee5ec6@tethys.solarsys.org> (raw)
In-Reply-To: <40E1BE97.1090209@ig.com.br>

Hello Luciano,


On Tue, 29 Jun 2004 16:10:15 -0300 Luciano Moreira - igLnx <lucianolnx@ig.com.br> wrote:

> Because, the compiler doesn't know the value of the symbol DEFSIZE when 
> it is used for a array declaration, like as:
> char myArray[MYCLASS::DEFSIZE];
> 
> Then, we have the conclusion that the value atribution should be in 
> header file (.h) - for that case. But, I tried the use of "enum", and 
> now it's working well.

Of course #define'd values can be used in array range. Such value is not
dynamically interpreted, since the pre processor is performing substitution of
macros before the compiler gets the file.

Did you try to maintain you const int in the header file and to encapsulate it
like this:

[beginning of .h file]
#ifndef MY_CLASS_H
#define MY_CLASS_H

// .. here the previous content of your .h file

#endif
[EOF]


My 2 cts..


Regards,

> Henry Margies wrote:
> 
> >Just put the definition in the cpp file.
> >
> >Header File:
> >class Foo
> >{
> >	public:
> >		static const int DEFSIZE;
> >};
> >
> >in CPP-File:
> >
> >const int Foo::DEFSIZE=100
> >
> >
> >Why does this not work for you?
> >
> >
> >Henry
> >
> >  
> >
> -
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
wwp

  reply	other threads:[~2004-07-02  7:47 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-28 22:46 "static const" attribute in C++ (How to ?) Luciano Moreira - igLnx
2004-06-28 23:52 ` Glynn Clements
2004-06-29 14:30   ` Luciano Moreira - igLnx
2004-06-29 17:26     ` Henry Margies
2004-06-29 19:10       ` Luciano Moreira - igLnx
2004-07-02  7:47         ` wwp [this message]
     [not found]           ` <40E56EFF.1030901@ig.com.br>
2004-07-02 14:30             ` Luciano Moreira - igLnx
2004-06-29 17:39     ` Glynn Clements
2004-06-29 14:32   ` Micha Feigin
2004-06-29 17:43     ` Glynn Clements
2004-06-30  1:33       ` Micha Feigin
2004-06-30  2:01         ` Glynn Clements
2004-06-30 23:42           ` Daniel Brockman
2004-07-01 22:33             ` Glynn Clements
2004-06-30 20:39         ` John Richard Moser
2004-06-30 22:31           ` Glynn Clements
2004-07-01  3:22             ` Micha Feigin
2004-07-01  4:27               ` Glynn Clements
2004-07-01  7:12             ` John Richard Moser
2004-06-29 19:08     ` Luciano Moreira - igLnx
  -- strict thread matches above, loose matches on Subject: below --
2004-07-02 10:20 Dinesh Ahuja
2004-07-02 14:29 ` Luciano Moreira - igLnx
2004-07-02 22:32 ` Glynn Clements
2004-07-03  0:12   ` Luciano Moreira - igLnx
2004-07-05  5:35     ` Dinesh Ahuja
2004-06-28 21:42 Luciano Moreira - igLnx
2004-06-28 21:52 ` Glynn Clements
2004-06-29  1:10 ` Micha Feigin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040702094755.73ee5ec6@tethys.solarsys.org \
    --to=subscript@free.fr \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=lucianolnx@ig.com.br \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).