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::DoSomething(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::DoSomething(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::DoSomething(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.
--
Karthik. 2 1820
"Karthik Kumar" <ka*****************@yahoo.com> wrote in message 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::DoSomething(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::DoSomething(const int)' : overloaded member function not found in 'Geometry::TrackBall' c:\temp\myns_myheader.h(8) : see declaration of 'MyNS::MyClass'
The error seems to be with your not providing an overload of DoSomething
taking one int as parameter. You can see that the compiler is deducing the
context as MyNS::MyClass::DoSomething in the error message. When I changed the C++ source code (with the fully-qualified name of the class as follows:
//no 'using' statement here
int MyNS::MyClass::DoSomething(int a, int b) { return a + b; }
I think the error message lies somewhere else.
Sharad
"Karthik Kumar" <ka*****************@yahoo.com> wrote in message
news:414818b9$1@darkstar... 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 );
This function takes two int parameters. But see below... }; }
#endif // Source file
#include "myns_myheader.h"
using MyNS::MyClass;
int MyClass::DoSomething(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::DoSomething(const int)' : overloaded member function not found in 'Geometry::TrackBall' c:\temp\myns_myheader.h(8) : see declaration of 'MyNS::MyClass'
This is complaining about not finding a DoSomething that takes a single
const int parameter. Look in the function TrackBall, as stated in the error
message. What are you calling there?
When I changed the C++ source code (with the fully-qualified name of the class as follows:
//no 'using' statement here
int MyNS::MyClass::DoSomething(int a, int b) { return a + b; }
Then it compiled successfully.
Without seeing the call in Geometry::TrackBall, who can tell? Is Geometry
in another namespace? I think that there are issues of "hiding" functions
called from one namespace to another in VS, which may be resolved by
specifying the namespace. But this isn't enough code for me to duplicate
the problem here. * What does the C++ language standard specify regarding this usage ?
What usage? Calling a function in a namespace? There is nothing in what
you've shown that in itself exhibits a problem. There must be a problem
caused by something in the code you haven't shown.
Who is correct - GCC / VS .NET ? Or, does it depend on the implementation ?
Thanks for clarifying this.
-- Karthik. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tony Johansson |
last post by:
Hello!
I have these two statements
typedef const char *enum_txt;
and
enum_txt phase_tab
={"IDLE","LAUNCHING","LAUNCHED","ROLLING","BOOSTERRELEASE","SPACE"};
where in the class definition...
|
by: Mike Hewson |
last post by:
Have been researching as to why:
<example 1>
class ABC
{
static const float some_float = 3.3f;
};
<end example 1>
|
by: Lee Franke |
last post by:
I can't seem to figure this one out.
Here is my class structure
namespace name
{
public class foo
{
}
}
|
by: +The_Taco+ |
last post by:
Ok i'm kinda new to ASP.NET. I got like 4 aspx pages right now, all with
there aspx.vb codebehind. Each of them need to connect on the same database,
so what I want to do is to create a module or a...
|
by: jerry.upstatenyguy |
last post by:
I am really stuck on this. I am trying to write a string array
containing a "word" and a "definition" to a class called Entry.
Ultimately this will end up in another class called dictionary. No,...
|
by: Mark Olbert |
last post by:
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c.
The problem I'm running into is that the root element needs to be unqualified,...
|
by: akomiakov |
last post by:
Is there a technical reason why one can't initialize a cost static non-
integral data member in a class?
|
by: Gaijinco |
last post by:
I'm trying to do a template class Node.
My node.hpp is:
#ifndef _NODE_HPP_
#define _NODE_HPP_
namespace com { namespace mnya { namespace carlos {
template <typename T>
|
by: greek_bill |
last post by:
Hi,
I'm trying to develop a system where I can register some data/
information about a class. For example
// ClassInfo.h
template <class T>
struct ClassInfo
{
static const std::string ...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |