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
14 4483
"<- Chameleon ->" <ch******@hotma il.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.comeaucompu ting.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 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...
|
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.
...
|
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
----------
|
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;
|
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
| |
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 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...
|
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:
|
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
|
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*...
|
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,...
| |
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...
|
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,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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();...
| |
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...
|
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...
| |