This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: Problem with code or gcc?
- From: Philippe Haution <philippe_haution at yahoo dot fr>
- To: "Kedzierski, Artur CIV NAVSURFWARCENDIV CORONA" <artur dot kedzierski at navy dot mil>, gcc-help at gcc dot gnu dot org
- Date: Tue, 27 Sep 2005 16:12:34 +0200 (CEST)
- Subject: RE: Problem with code or gcc?
- Reply-to: philippe dot haution at mines-paris dot org
Hello,
This is not a valid C++ code, you cannot define the
value of CONST inside the struct declaration.
A more correct code would be :
struct MyStruct {
static const int CONST;
};
const int MyStruct::CONST = 1;
Regards,
PH
--- "Kedzierski, Artur CIV NAVSURFWARCENDIV CORONA"
<artur.kedzierski@navy.mil> a écrit :
> Could anybody tell me if this is a valid C++ code
> or
> a problem with GCC?
>
> test_prog.cc:
> #include <vector>
> struct MyStruct {
> static const int CONST = 1;
> };
>
> int main() {
> std::vector<int> l;
> MyStruct z;
> l.push_back(z.CONST);
> }
>
>
> I get an undefined reference to MyStruct::CONST
> when
> I try to compile it.
> I appreciate any help.
>
> Artur Kedzierski
>
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez cette version sur http://fr.messenger.yahoo.com