I read in "Thinking in C++" this code works:
---------
class A
{
static const int b = 1;
};
---------
but it doesn't!
I do something wrong?
I use VC++6 and it returns:
-------
error C2258: illegal pure syntax, must be '= 0'
error C2252: 'b' : pure specifier can only be specified for functions
------- 14 4451
<- Chameleon -> wrote: I read in "Thinking in C++" this code works: --------- class A { static const int b = 1; }; --------- but it doesn't! I do something wrong?
No. VC6 is non-standard in this matter. The usual fix is the enum-as-const
"idiom". Just do it like this:
class A
{
enum { b = 1; };
};
--
WW aka Attila
"WW" <wo***@freemail.hu> wrote... <- Chameleon -> wrote: I read in "Thinking in C++" this code works: --------- class A { static const int b = 1; }; --------- but it doesn't! I do something wrong? No. VC6 is non-standard in this matter. The usual fix is the
enum-as-const "idiom". Just do it like this:
class A { enum { b = 1; };
enum { b = 1 };
};
Victor
Victor Bazarov wrote:
[...] enum { b = 1; };
enum { b = 1 };
"The actual eyeballs, lying within an ea^H^H^H^H^HBazarov's skull, are
huge by our standards, taking up more room than the brain itself!" http://amos.indiana.edu/library/scripts/eagle.html
regards,
alexander.
Victor Bazarov wrote: class A { enum { b = 1; };
enum { b = 1 };
};
Thanks for the correction. I forgot to remove the ;. It is so little I did
not see it is there. That is again a proof that size does not matter ;-)
--
WW aka Attila
Alexander Terekhov wrote: Victor Bazarov wrote: [...] enum { b = 1; };
enum { b = 1 };
"The actual eyeballs, lying within an ea^H^H^H^H^HBazarov's skull, are huge by our standards, taking up more room than the brain itself!"
I assume Alexander meant you have eagle eyes. And nothing about Victor's
brain.
Alexander, you will really need a bodyguard. My father has jokes like this
and the people of his village did confess to me that they have sometimes
played with the idea to check if his brain differs from a normal one. ;-)
--
WW aka Attila
"WW" <wo***@freemail.hu> wrote... [...] I assume Alexander meant [...]
He didn't mean anything. He can't mean anything.
He has no device with which to mean.
Victor Bazarov wrote: "WW" <wo***@freemail.hu> wrote... [...] I assume Alexander meant [...]
He didn't mean anything. He can't mean anything. He has no device with which to mean.
I see. He has no device with which to mean. So he cannot be mean. ;-)
WW wrote:
[...] I assume Alexander meant you have eagle eyes. And nothing about Victor's brain.
Let me put it this way. Judging from Bazarov's "subdue" c.l.c++-policing
activity of lately, his medical treatment looks really promising. To me,
it seems like he'll reach the level of NeilB really soon. Amen. Default,
be ready (never mind your days are coming too). http://groups.google.com/groups?selm...A3F4C%40web.de
regards,
alexander.
Alexander Terekhov wrote: WW wrote: [...]
I assume Alexander meant you have eagle eyes. And nothing about Victor's brain.
Let me put it this way. Judging from Bazarov's "subdue" c.l.c++-policing activity of lately, his medical treatment looks really promising. To me, it seems like he'll reach the level of NeilB really soon. Amen. Default, be ready (never mind your days are coming too).
http://groups.google.com/groups?selm...A3F4C%40web.de
So what did end up happening to the butter man. Is he Alexander now ?
"<- Chameleon ->" <ch******@hotmail.NOSPAM.com> wrote in message news:<bk*********@nic.grnet.gr>... I read in "Thinking in C++" this code works: --------- class A { static const int b = 1; }; --------- but it doesn't!
<http://www.comeaucomputing.com/tryitout/> compiles it just fine. If
you're going to use a compiler as a measure of code correctness, use
that one. :)
I do something wrong? I use VC++6 and it returns: ------- error C2258: illegal pure syntax, must be '= 0' error C2252: 'b' : pure specifier can only be specified for functions -------
VC++6 is wrong. VC++.NET compiles it.
In the short term, maybe try this instead:
class A { enum { b = 1 }; };
Or, if you don't need it as a compile-time constant (e.g., for use as
a template parameter, size of an array, etc.), initialize it when you
define it in a .cpp file:
// A.h
class A {
static const int b;
};
// A.cpp
const int A::b = 1;
- Shane
"WW" <wo***@freemail.hu> wrote... Victor Bazarov wrote: "WW" <wo***@freemail.hu> wrote... [...] I assume Alexander meant [...]
He didn't mean anything. He can't mean anything. He has no device with which to mean.
I see. He has no device with which to mean. So he cannot be mean. ;-)
Nah. It's actually simpler. He cannot be. Unless you let him,
by replying to his nonsense. Two more times and you (and others
feeding that idiot troll) will probably join him in my killfile.
You don't have to care about that. I'm just pondering.
Victor Bazarov wrote: Nah. It's actually simpler. He cannot be. Unless you let him, by replying to his nonsense. Two more times and you (and others feeding that idiot troll) will probably join him in my killfile. You don't have to care about that. I'm just pondering.
If you killfile me I cannot send you my C++ language proposal for review.
It would be shame. How do you expect *me* to get it right? Drop me a mail
if you think you would have time and want to look at something like that.
BTW I was not trying to feed any troll, I was trying to keep the tension
down. Well, remind me time to time to not seek for a carrier in marriage
concunciling. :-(
--
WW aka Attila
WW wrote:
[SNIP] tension down. Well, remind me time to time to not seek for a carrier in marriage concunciling. :-(
And to not to teach spelling..
--
WW aka Attila
Victor Bazarov wrote: "WW" <wo***@freemail.hu> wrote... Victor Bazarov wrote: "WW" <wo***@freemail.hu> wrote... > [...] > I assume Alexander meant [...]
He didn't mean anything. He can't mean anything. He has no device with which to mean. I see. He has no device with which to mean. So he cannot be mean. ;-)
Nah. It's actually simpler. He cannot be. Unless you let him, by replying to his nonsense. Two more times and you (and others feeding that idiot troll) will probably join him in my killfile.
Aha. How scary.
You don't have to care about that. I'm just pondering.
Medication, Bazarov. Take a dose of anti-hysteria pills.
regards,
alexander. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DanielBradley |
last post by:
Hello all,
I have recently been porting code from Linux to cygwin and came across
a problem with static const class members (discussed below). I am
seeking to determine whether I am programming...
|
by: Steven T. Hatton |
last post by:
Sorry about the big code dump. I tried to get it down to the minimum
required to demonstrate the problem. Although this is all done with GNU, I
believe the problem I'm having may be more general. ...
|
by: Jonas Cord |
last post by:
Hi, I'm trying to learn proxy classes in C++ so I've written the
following code, trying to modify an example given in Deitel & Deitel's
C++ book.
I am trying to "hide" details of the original...
|
by: Not Available |
last post by:
On the host server:
namespace JCart.Common
public class JCartConfiguration : IConfigurationSectionHandler
private static String dbConnectionString;
public static String ConnectionString
{
get...
|
by: mast2as |
last post by:
Hi guys
Here's the class I try to compile (see below). By itself when I have a
test.cc file for example that creates an object which is an instance of
the class SpectralProfile, it compiles...
|
by: Gary Wessle |
last post by:
Hi
how can I initialize a const char* myarr in a class constructor?
class Myclass {
const char* myarr = { "abc", "def" };
....
};
|
by: Bern McCarty |
last post by:
I have a simple ref class in its own namespace that needs to coexist with
a legacy typedef alias for "unsigned int" in the global namespace that has
the identifier as itself. Everything compiles...
|
by: David Sanders |
last post by:
Hi,
As part of a simulation program, I have several different model
classes, ModelAA, ModelBB, etc., which are all derived from the class
BasicModel by inheritance.
model to use, for example...
|
by: Per Bull Holmen |
last post by:
Hey
Im new to c++, so bear with me. I'm used to other OO languages, where it
is possible to have class-level initialization functions, that
initialize the CLASS rather than an instance of it....
|
by: alan |
last post by:
Hello world, I'm wondering if it's possible to implement some sort of
class/object that can perform mapping from class types to strings?
I will know the class type at compile time, like so:...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
| |