Error C2555
c:\C++ projects\stat1\ stdmatrix_adapt .h(41) : error C2555:
'std_tools::Mat rix_adapter<T>: :at': overriding virtual function return
type differs and is not covariant from 'ple::imtx_impl <T>::at'
//in my program: the derived class
template <class T>
class Matrix_adapter : public ple::imtx_impl< T{
protected:
Matrix* m_;
public:
virtual const T& at(mtx_size i0, mtx_size i1) const //mtx_size -->
unsigned int
{return m_->at(i0, i1);}
}
// the base class
template <class T>
class imtx_impl : public imtx<T{
virtual const T& at(mtx_size i0, mtx_size i1) const=0;
/*Notice Matrix_adapter. at returns a pointer to another class Matrix
m_
The problem arises as this class Matrix has no template instantiation
and i set the virtual function at return as double, the same as T */
class Matrix : public GeneralMatrix
public:{
const double& at(unsigned int pos0, unsigned int pos1) const { return
v_.at(c_(pos0, pos1)); }
}
// However in my main program initiating T as double in the derived
class still gives the error C2555.
Matrix_adapter <doublematx;
Am at loss what to do now.. any people care to help... ? 3 2961 er*********@gma il.com wrote:
Error C2555
c:\C++ projects\stat1\ stdmatrix_adapt .h(41) : error C2555:
'std_tools::Mat rix_adapter<T>: :at': overriding virtual function return
type differs and is not covariant from 'ple::imtx_impl <T>::at'
//in my program: the derived class
template <class T>
class Matrix_adapter : public ple::imtx_impl< T{
protected:
Matrix* m_;
public:
virtual const T& at(mtx_size i0, mtx_size i1) const //mtx_size -->
unsigned int
{return m_->at(i0, i1);}
}
// the base class
template <class T>
class imtx_impl : public imtx<T{
virtual const T& at(mtx_size i0, mtx_size i1) const=0;
/*Notice Matrix_adapter. at returns a pointer to another class Matrix
m_
The problem arises as this class Matrix has no template instantiation
and i set the virtual function at return as double, the same as T */
class Matrix : public GeneralMatrix
public:{
const double& at(unsigned int pos0, unsigned int pos1) const { return
v_.at(c_(pos0, pos1)); }
}
// However in my main program initiating T as double in the derived
class still gives the error C2555.
Matrix_adapter <doublematx;
Am at loss what to do now.. any people care to help... ?
The code fragments as posted look OK, can you reproduce the problem with
a self contained example?
--
Ian Collins.
On Mar 5, 1:50 pm, Ian Collins <ian-n...@hotmail.co mwrote:
erictham...@gma il.com wrote:
Error C2555
c:\C++ projects\stat1\ stdmatrix_adapt .h(41) : error C2555:
'std_tools::Mat rix_adapter<T>: :at': overriding virtual function return
type differs and is not covariant from 'ple::imtx_impl <T>::at'
//in my program: the derived class
template <class T>
class Matrix_adapter : public ple::imtx_impl< T{
protected:
Matrix* m_;
public:
virtual const T& at(mtx_size i0, mtx_size i1) const //mtx_size -->
unsigned int
{return m_->at(i0, i1);}
}
// the base class
template <class T>
class imtx_impl : public imtx<T{
virtual const T& at(mtx_size i0, mtx_size i1) const=0;
/*Notice Matrix_adapter. at returns a pointer to another class Matrix
m_
The problem arises as this class Matrix has no template instantiation
and i set the virtual function at return as double, the same as T */
class Matrix : public GeneralMatrix
public:{
const double& at(unsigned int pos0, unsigned int pos1) const { return
v_.at(c_(pos0, pos1)); }
}
// However in my main program initiating T as double in the derived
class still gives the error C2555.
Matrix_adapter <doublematx;
Am at loss what to do now.. any people care to help... ?
The code fragments as posted look OK, can you reproduce the problem with
a self contained example?
--
Ian Collins.- Hide quoted text -
- Show quoted text -
Ya i thought the derived and base classes look ok. Except that the
class that the pointer points is not a template class. er*********@gma il.com wrote:
On Mar 5, 1:50 pm, Ian Collins <ian-n...@hotmail.co mwrote:
>erictham...@gm ail.com wrote:
>>Error C2555
>>c:\C++ projects\stat1\ stdmatrix_adapt .h(41) : error C2555: 'std_tools::M atrix_adapter<T >::at': overriding virtual function return type differs and is not covariant from 'ple::imtx_im pl<T>::at'
>>//in my program: the derived class template <class T> class Matrix_adapter : public ple::imtx_impl< T{ protected: Matrix* m_; public: virtual const T& at(mtx_size i0, mtx_size i1) const //mtx_size --unsigned int {return m_->at(i0, i1);} } // the base class template <class T> class imtx_impl : public imtx<T{ virtual const T& at(mtx_size i0, mtx_size i1) const=0;
>>/*Notice Matrix_adapter. at returns a pointer to another class Matrix m_ The problem arises as this class Matrix has no template instantiati on and i set the virtual function at return as double, the same as T */
>>class Matrix : public GeneralMatrix public:{ const double& at(unsigned int pos0, unsigned int pos1) const { return v_.at(c_(pos0, pos1)); } }
>>// However in my main program initiating T as double in the derived class still gives the error C2555.
>>Matrix_adapte r <doublematx;
>>Am at loss what to do now.. any people care to help... ?
The code fragments as posted look OK, can you reproduce the problem with a self contained example?
-- Ian Collins.- Hide quoted text -
- Show quoted text -
Ya i thought the derived and base classes look ok. Except that the
class that the pointer points is not a template class.
There is no such think in C++ as "template class". There is a class
template and there is a class generated from a template (a template
instantiation). Please adjust your statement and explain what (or
which) you mean.
You didn't post what 'imtx' template looked like, you didn't post
any code that uses your template (which would show instantiation of it
and the template arguements). Please consult with FAQ 5.8 for further
clarification.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alf P. Steinbach |
last post by:
// As usual the error message directs one to the report the bug.
//
// And as usual there is absolutely no way to do so without paying for
// the privilege...
//
// Or using three or four hours to find the _current_ reporting page...
#include <vector>
#include <iostream>
|
by: Drew McCormack |
last post by:
I have a C++ template class which contains a static variable whose
construction registers the class with a map. Something like this:
template <typename T>
class M {
static Registrar<M> registrar;
};
The constructor of Registrar does the registering when it is initialized.
|
by: Rudy Ray Moore |
last post by:
Whenever I get any error with Vc++7.1/.net/2003, it is followed by huge
ammounts of "template assistance" error messaging referencing template code
(MTL) that has nothing to do with the error.
This makes it difficult to spot errors. For example, F4 to "jump to next
error" just jumps ot the next "template assistance" message. And since
there are hundreds of them, this is quite obnoxious.
Can I disable these things? Why is MSVC...
|
by: dilip ranganathan |
last post by:
Hi
I have taken the liberty to cross-post this. It appeared on c.l.c++.m
but the ICE is regarding VS.NET 7.1 C++ compiler.
post follows:
==============================================
John Torjo wrote:
>
|
by: hyd |
last post by:
Hello,
I use VS2005 - C++/CLI.
I have some kind of events in native C++. I want to raise .NET events
when my native C++ events occur.
So, I wrote some code for that but I have an C1001 error (An internal
error has occurred in the compiler).
Below, a piece of code that produces the same error :
***** CLR - Class Library project *****
| |
by: dascandy |
last post by:
The following program produces no warnings, no errors, but doesn't do
what I expect it to. I expect it to produce a warning or error. What
does the standard say about this and/or what should it say? Stroustrup
mentions it's an error (The C++ programming language, p343) but
doesn't say whether the standard says so or whether it's
implementation defined.
Both GCC and MSVC return "4 4 40", showing they instantiated the
template at the...
|
by: hsmit.home |
last post by:
Hello,
I came across a strange error and it's really been bugging me. Maybe
someone else has come across this and any insight would be
appreciated.
What I'm trying to accomplish is using boost::lexical_cast to cast a
vector of strings to a string.
The compiler I'm using is MSVC++ 2005 Express Edition. The gc++
|
by: Francesco |
last post by:
Hi to all,
The code below is a ( very ) simplified example of the problem I'm
facing.
// CODE
template< typename T >
class A
{
public:
|
by: Pallav singh |
last post by:
Hi All,
i am getting error during explicit function Instantiation for a class
Template
if i do explicit Instantiation of class it work and all function
symbol i get in object file
But if i try to expose only one function of my class its failing
#include <iostream>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |