473,395 Members | 1,631 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,395 software developers and data experts.

template specialization compile error

Hello All.
I am trying to compile this code on Borland 5.6.4. The compiler is
throwing up this error message:

"main.cpp": E2299 Cannot generate template specialization from 'B<T>'
at line 12

Any help to fix this would be appreciated.

--Naveen.
// -------------------- Code Starts here ----------------------------
//
#include <iostream>

class A { };

template <typename T>
class B : public A
{
public: B() { }
};

class Testing
{
public:
template <typename T>
void load( int key, B<T>& sort = B<T>())
{
}
};

void main()
{
Testing ab;
ab.load<int>(10);
}
//
// -------------------- End of Code -----------------------
Jul 22 '05 #1
1 2096

"Naveen" <ns******@gmail.com> wrote in message
Hello All.
I am trying to compile this code on Borland 5.6.4. The compiler is
throwing up this error message:

"main.cpp": E2299 Cannot generate template specialization from 'B<T>'
at line 12

Any help to fix this would be appreciated.

--Naveen.
Two errors are apparent to me.

// -------------------- Code Starts here ----------------------------
//
#include <iostream>

class A { };

template <typename T>
class B : public A
{
public: B() { }
};

class Testing
{
public:
template <typename T> void load( int key, B<T>& sort = B<T>())
ISO C++ forbids binding rvalues to non-const references. So the reference
should be to a const object.
void load( int key, const B<T>& sort = B<T>())
^^^^ { }
};

void main()
main has never ever in the history of C++ returned void. The return type is
int.
{
Testing ab;
ab.load<int>(10);
}
//


Sharad
Jul 22 '05 #2

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

Similar topics

2
by: Jeff | last post by:
/* -------------------------------------------------------------------------- Hello, I was experimenting with class templates and specializing member functions and came across a simple problem...
6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
13
by: Walt Karas | last post by:
The following gives an error in the declaration of the member function x() of the class template Tpl, compiliing with a recent version of GCC under Solaris: class A { }; class B { }; ...
5
by: Amit | last post by:
Greetings all, I am writing some code somehwat similar to the test code I have below. I am having a variety of issues with template specialization. I am not sure if this is related to something...
5
by: Levent | last post by:
Hi, Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1): #include <iostream> template<class T, unsigned N> struct Foo { void func(); }; template<class T, unsigned N>
2
by: Michael Stembera | last post by:
Here is a very simple piece of code to repro this bug. template<typename T, int N> inline bool foo( void ) { return true; } template<typename T> inline bool foo<T, 1>( void ) { return...
1
by: Michael Stembera | last post by:
I have a case of a very simple template class w/ a template method. If I define a specialization of the method outside the body of the template class it does not compile. Here is a tiny example...
1
by: ranges22 | last post by:
****************************************************************** I am compiling a librarry which has a .h file containing th following:...
2
by: Yang Zhang | last post by:
I have a small program like this: //////////////////////////////////////////////// #include <iostream> using namespace std ; // set bits in an address template <typename T> inline T*...
2
by: Nick | last post by:
I'm learning C++ and ran into a compile error using Visual C++ 2005 Express on the following example program (located at http://www.cplusplus.com/doc/tutorial/templates.html): // template...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.