473,799 Members | 3,167 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

class A{static const int b = 1; };

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
-------
Jul 19 '05 #1
14 4482
WW
<- 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
Jul 19 '05 #2
"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
Jul 19 '05 #3

Victor Bazarov wrote:
[...]
enum { b = 1; };


enum { b = 1 };


"The actual eyeballs, lying within an ea^H^H^H^H^HBaz arov'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.
Jul 19 '05 #4
WW
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
Jul 19 '05 #5
WW
Alexander Terekhov wrote:
Victor Bazarov wrote:
[...]
enum { b = 1; };


enum { b = 1 };


"The actual eyeballs, lying within an ea^H^H^H^H^HBaz arov'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
Jul 19 '05 #6
"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.
Jul 19 '05 #7
WW
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. ;-)
Jul 19 '05 #8

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.
Jul 19 '05 #9
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 ?

Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3615
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 non-standard C++ or if the problem lies elsewhere. To summarize static const class members are not being accessed properly when accessed from a DLL by another external object file (not within the DLL). It only occurs when the static const...
3
2239
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. Someone on the SuSE programming mailing list suggested my problem is that I'm trying to execute a function (I assume he meant the constructor) at compile time. The same source code compile if I don't try to split it up into separate libraries. ...
2
3790
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 class (employee.h) through a proxy class (employeeproxy.h). What am I doing wrong? Please help... I will be grateful forever. employee.h ----------
10
3489
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 { return dbConnectionString;
5
3610
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 fine. 1 / Now If I move the getSpectrumAtDistance( const T &dist ) method definition in SpectralProfofile.cc let's say the compiler says core/profile.cc:199: error: `kNumBins' was not declared in this scope
14
2116
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" }; .... };
8
1729
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 fine with the old MEC++ syntax, but I cannot figure out how to write the code so that it will compile in C++/CLI. Can someone tell me how? Here is the code in both syntaxes: // This MEC++ code compiles just fine with VC8 using cl -c...
25
2150
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 if the parameter model_name is "aa", then choose ModelAA. Currently I do this as follows:
8
8932
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. Like, for instance the Objective-C method: +(void)initialize Which has the following characteristics: It is guaranteed to be run
5
2576
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: const char *s = string_mapper<thetype>(); However I do not know the string to be associated with the type at compile time, and will need a way to set up the mapping, to be created at run time, possibly like so: void foo(char*...
0
10473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10249
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10219
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5584
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.