Home Dashboard Directory Help
Search

Static const member variable defined multiple times by Kaba_


Status: 

Closed
 as By Design Help for as By Design


0
0
Sign in
to vote
Type: Bug
ID: 379496
Opened: 11/2/2008 3:47:12 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

test.h:

#ifndef TEST_H
#define TEST_H

class Test
{
public:
    static const int V = 2;
};

#endif

test.cpp:

#include "test.h"
const int Test::V;

main.cpp:

#include "test.h"

int main()
{
    return 0;
}
Details
Sign in to post a comment.
Posted by Microsoft on 11/3/2008 at 7:46 AM
Hi: this is By-Design - experience showed that most users considered the declaration + initialization within the class to be a definition and hence they didn't understand why the needed (in some circumstances) to define the member outside of the class.

As you said the compiler handles this correctly with /Za.

Jonathan Caves
Visual C++ Compiler Team
Posted by Microsoft on 11/2/2008 at 10:24 PM
Thanks for your feedback.

We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.

Thank you,
Visual Studio Product Team
Sign in to post a workaround.