473,699 Members | 2,834 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 4469
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
3600
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
2234
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
3782
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
3481
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
3602
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
2103
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
1723
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
2142
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
8925
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
2572
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
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9032
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
8905
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,...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
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
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
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
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.