473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

"unable to match function definition to an existing declaration"

Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned long)'
existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett
Sep 10 '05 #1
5 6284

"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
Your code compiles OK for me with VC++ v6.0(SP6).


I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)'
T2? I don't see that anywhere in your posted code.
Have you made a typo somewhere and the above isn't the real code? :-)

existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?


-Mike
Sep 10 '05 #2

"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)'
existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett


Looks like a compiler bug. VC++ 2005 Beta 2 compiles the code just fine.

Ben
Sep 10 '05 #3
Mike Wahler:

"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
Your code compiles OK for me with VC++ v6.0(SP6).


For me the code also compiled ok with VC++ 6.0 (SP5);
I'm migrating to VC++.NET 2003.


I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)'
T2? I don't see that anywhere in your posted code.
Have you made a typo somewhere and the above isn't the real code? :-)


Unfortunately it really *is* what VC says.
I don't use T2; no idea where the compiler takes it from.

existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?


-Mike


Maett
Sep 10 '05 #4
"Maett" <no@spam.pls> wrote in message news:opswv68avtmmfhfz@max
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iterator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>::TableType::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T>::FindErr' : unable to match
function definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T>::FindErr'
definition
'std::vector<T,T2>::iterator MarkerTable<T>::FindErr(unsigned
long)' existing declarations
'vector<Marker<T>>::iterator MarkerTable<T>::FindErr(unsigned
long)'
Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett


Apparently it is a VC++2003 bug. You can work around it by not using the
typedef from MarkerTable when defining FindErr, i.e., make it:

template< class T >
typename std::vector< Marker<T> >::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
}

--
John Carson

Sep 11 '05 #5
John Carson wrote:

Apparently it is a VC++2003 bug. You can work around it by not using the
typedef from MarkerTable when defining FindErr, i.e., make it:

template< class T >
typename std::vector< Marker<T> >::iterator
MarkerTable<T>::FindErr( unsigned long n )
{
typename TableType::iterator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
}


Great, this works.
Thanks a lot !

Maett
Sep 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hartmut Sbosny | last post by:
Hello NG, I have a question. I have a header file with a function template and a fully specialized version of it, for instance //======== File "templ.hpp" ======== #include <iostream> // the...
10
by: Kobu | last post by:
My question is about the use and meaning of the terms "declaration" and "definition" as it pertains to the C language. I've read sources that mix the two up when talking about such things as...
4
by: octavio | last post by:
Hello members of the comp.lang.c newsgroup. Please I need you help on the following one. Compiling the simple code I'm getting this error message. Why ? Please what's the correct type of the fb...
1
by: sathyp | last post by:
Public Function SetPrinterDefaultsW(ByVal sPrinterName As String, _ ByVal nPaperSize As Long, ByVal nOrientation As Long) As Boolean Dim Prn As Printer Dim hPrinter As Long Dim pd As...
33
by: Chen shuSheng | last post by:
I have a code: --------------------------- #include <iostream.h> #include <stdlib.h> int main() { int max=15; char line; getline(line,max); system("PAUSE");
12
by: Jon Slaughter | last post by:
is there any way to simply add an attribute like feature to a function/method definition? say I create a function like function Test() { //.... }
3
by: Good Man | last post by:
Hi there Ideally, I'd like to create one javascript function and pass the file extension i'm looking for to see if its there: <input type="file" onchange="checkFile('pdf',this)" /> and then...
5
by: Fred Hebert | last post by:
I was thinking of switching to VS2005, so I sent off for and received a 120 evaluation kit. This version was supposed to be the same as the full version, but the key limits you to 120 days. I...
4
by: DR | last post by:
when i build someone's project, and right click a function "goto definition" is disabled. how to reconfigure a .net project to support "goto definition" when i right click on function calls?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.