Re: Declaring constants within the scope of a class
From: Shezan Baig (shezanbaig2004_at_gmail.com)
Date: 03/15/05
- Next message: Howard: "Re: polymorphism, overloading..."
- Previous message: Victor Bazarov: "Re: polymorphism, overloading..."
- In reply to: Generic Usenet Account: "Declaring constants within the scope of a class"
- Next in thread: Howard: "Re: Declaring constants within the scope of a class"
- Reply: Howard: "Re: Declaring constants within the scope of a class"
- Reply: Victor Bazarov: "Re: Declaring constants within the scope of a class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 15 Mar 2005 08:17:28 -0800
Generic Usenet Account wrote:
> I am trying to compile the following sample code:
>
> class WhatISHappeningHere
> {
> static const int x = 32;
> static const char* yy = "Howdy";
> // ...
> // blah blah blah
> // ...
> };
>
>
> My GCC compiler (g++ version 2.95.2) is giving the following
misleading
> compiler error:
>
> ANSI C++ forbids in-class initialization of non-const static member
> `yy'
>
>
> I suspect that initialization of static data members that are not of
an
> integral type is not allowed in C++, but the compiler is giving a
wrong
> error message. Kindly confirm/refute my observation.
>
> Thanks,
> Gus
I'm not sure if this will work, but try:
static const char* const yy = "Howdy";
- Next message: Howard: "Re: polymorphism, overloading..."
- Previous message: Victor Bazarov: "Re: polymorphism, overloading..."
- In reply to: Generic Usenet Account: "Declaring constants within the scope of a class"
- Next in thread: Howard: "Re: Declaring constants within the scope of a class"
- Reply: Howard: "Re: Declaring constants within the scope of a class"
- Reply: Victor Bazarov: "Re: Declaring constants within the scope of a class"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|