K
Karthik Kumar
Hi,
I was writing this application that used namespaces.
The structure of the file was as follows.
//Header file
#ifndef MYNS_MYHEADER_H
#define MYNS_MYHEADER_H
namespace MyNS {
class MyClass {
//Declare methods and fields.
int DoSomething(int , int );
};
}
#endif
// Source file
#include "myns_myheader.h"
using MyNS::MyClass;
int MyClass:oSomething(int a, int b) {
return a + b;
}
With GCC 3.3.1 - This code compiles correctly.
With MS VC .NET compiler - the compiler errors out .
error C2511: 'void MyNS::MyClass:oSomething(const int)' : overloaded
member function not found in 'Geometry::TrackBall'
c:\temp\myns_myheader.h(8) : see declaration of 'MyNS::MyClass'
When I changed the C++ source code (with the fully-qualified name of the
class as follows:
//no 'using' statement here
int MyNS::MyClass:oSomething(int a, int b) {
return a + b;
}
Then it compiled successfully.
* What does the C++ language standard specify regarding this usage ?
Who is correct - GCC / VS .NET ? Or, does it depend on the
implementation ?
Thanks for clarifying this.
I was writing this application that used namespaces.
The structure of the file was as follows.
//Header file
#ifndef MYNS_MYHEADER_H
#define MYNS_MYHEADER_H
namespace MyNS {
class MyClass {
//Declare methods and fields.
int DoSomething(int , int );
};
}
#endif
// Source file
#include "myns_myheader.h"
using MyNS::MyClass;
int MyClass:oSomething(int a, int b) {
return a + b;
}
With GCC 3.3.1 - This code compiles correctly.
With MS VC .NET compiler - the compiler errors out .
error C2511: 'void MyNS::MyClass:oSomething(const int)' : overloaded
member function not found in 'Geometry::TrackBall'
c:\temp\myns_myheader.h(8) : see declaration of 'MyNS::MyClass'
When I changed the C++ source code (with the fully-qualified name of the
class as follows:
//no 'using' statement here
int MyNS::MyClass:oSomething(int a, int b) {
return a + b;
}
Then it compiled successfully.
* What does the C++ language standard specify regarding this usage ?
Who is correct - GCC / VS .NET ? Or, does it depend on the
implementation ?
Thanks for clarifying this.