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

template question again

The following codes can't pass compilation in vc7.1,
error occured at the possition where Foo is called.

************************************************** **********8
template<typename type>
class base1
{
template<typename type> class base2;
private:
typedef base2<type> base2type;
public:
virtual void Foo(base2type*)=0;
};

template<typename type2>
class base2
{
};

template<typename type>
class derive
:public base1<type>
,public base2<type>
{
typedef base2<type> base2type;
virtual void Foo(base2type*){}
};

int main(int argc, char* argv[])
{
derive<unsigned> * devptr=new derive<unsigned>;
base1<unsigned> * baseptr=devobj;
baseptr->Foo(devptr);
return 0;
}
Nov 17 '05 #1
1 991
the problem is solved thanks

"booker" <hu**********@kingsoft.net> дÈëÓʼþ
news:uZ**************@tk2msftngp13.phx.gbl...
The following codes can't pass compilation in vc7.1,
error occured at the possition where Foo is called.

************************************************** **********8
template<typename type>
class base1
{
template<typename type> class base2;
private:
typedef base2<type> base2type;
public:
virtual void Foo(base2type*)=0;
};

template<typename type2>
class base2
{
};

template<typename type>
class derive
:public base1<type>
,public base2<type>
{
typedef base2<type> base2type;
virtual void Foo(base2type*){}
};

int main(int argc, char* argv[])
{
derive<unsigned> * devptr=new derive<unsigned>;
base1<unsigned> * baseptr=devobj;
baseptr->Foo(devptr);
return 0;
}

Nov 17 '05 #2

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

Similar topics

2
by: Xenos | last post by:
The new version of GCC is out and in its list of changes, it talks about the C++ Standard's requirements for using the typename and template keywords to disambiguate dependent names. I'm use to...
1
by: Alfonso Morra | last post by:
if I have a class template declared as ff: (BTW is this a partial specialization? - I think it is) template <typename T1, myenum_1 e1=OK, my_enum_2=NONE> class A { public: A(); virtual...
9
by: Marek Vondrak | last post by:
Hello. I have written the following program and am curious why it prints "1" "2". What are the exact effects of explicitly providing function template parameters at the call? Is the second...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
45
by: charles.lobo | last post by:
Hi, I have recently begun using templates in C++ and have found it to be quite useful. However, hearing stories of code bloat and assorted problems I decided to write a couple of small programs...
3
by: toton | last post by:
Hi, I want to specialize template member function of a template class . It is creating some syntax problem .... Can anyone say how to do it ? The class is something like this template<typename...
8
by: 2b|!2b==? | last post by:
I have the ff template class: template <class T1, class T2class Periodic ; I have two questions/problems Q1). I want to specialize it further into two template classes:
9
by: stephen.diverdi | last post by:
Can anyone lend a hand on getting this particular template specialization working? I've been trying to compile with g++ 4.1 and VS 2005. ...
4
by: * Tong * | last post by:
First of all, thanks mlimber for answering my previous question. Now... I'm following the example in "C++ Templates: The Complete Guide", section 5.4 Template Template Parameters, and I'm...
32
by: Stephen Horne | last post by:
I've been using Visual C++ 2003 for some time, and recently started working on making my code compile in GCC and MinGW. I hit on lots of unexpected problems which boil down to the same template...
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: 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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
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
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.