473,387 Members | 1,899 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.

parse error in gcc but success in vc.net, call a non_template class's template member function from a template class's member function!

ken
the test code is :
/////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>

class CA
{
public:
template <typename T>
T Fun()
{
return T();
}
};
template<>
void CA::Fun<void>()
{
printf("in void\n");
return;
}

template <typename T>
class CB
{
public:
int operator()(T a1=T())
{
printf("aaa\n");
CA a;
a.Fun<T>(); //error this line
return 0;
}
};

int main()
{
CB<int> b;
b();
return 0;
}

/////////////////////////////////////////////////////////////////

the gcc 3.2.2 compiler report a error:
testtemp.cpp: In member function `int CB<T>::operator()(T)':
testtemp.cpp:37: parse error before `;' token

what's the matter? everything is right in the vc.net 7.1?

Jul 23 '05 #1
2 1560
On Fri, 24 Jun 2005 12:13:43 +0400, ken <lo*********@gmail.com> wrote:

[]
the gcc 3.2.2 compiler report a error:
testtemp.cpp: In member function `int CB<T>::operator()(T)':
testtemp.cpp:37: parse error before `;' token

what's the matter? everything is right in the vc.net 7.1?


Looks like a gcc bug. The code compiles fine with g++ 3.4.3 and 4.0.0 and
comeau online.

--
Maxim Yegorushkin
Jul 23 '05 #2
ken
it seems that I have to update my gcc :(
thank you!

Jul 23 '05 #3

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

Similar topics

2
by: André Somers | last post by:
Hi, I'm having a problem that I have a hard time understanding. I am getting a "Fatal error: Call to a member function on a non-object" on a constructor of a class, that looks like this...
2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
0
by: Zach | last post by:
Using Dev-C++ 4.9.8.5 I get error: Compiler: Default compiler Executing g++.exe... g++.exe "C:\winroot\src\c++\stupid_tricks\functor_trick.cpp" -o...
4
by: Kain0o0 | last post by:
Hello , thanks for any help in advance. Im writing some code for a c++ class and the proffessor wants us to implement a list template using arrays. I thought this would be an easy task but have...
7
by: Ook | last post by:
What am I doing wrong? This code gives a compile error: 'SortedList<T>::insert' : illegal call of non-static member function. I've tried several variations of this, but keep getting the same error....
13
by: Aston Martin | last post by:
can anyone point out why compiler is not happy ? it finds ambiguity in the friend function declaration and its implementation. if you eliminate the 'dummy' template parameter altogether, it works....
6
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. ...
1
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I...
6
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...
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: 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
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:
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
Oralloy
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,...
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.