473,666 Members | 1,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

template typedef as return type

Hello,

consider a class with a member function:

template<class schema>
class A
{
schema::t func();
};

template<class schema>
schema::t A<schema>::func ()
{ .... }

The 't' is a type, which will be defined via typedef later, in the schema
class.
It takes the error
'f': unable to resolve function overload
(I compiled it with VC++ 5.0)
Putting "typename schema" or "typename schema::t" in the declaration of A
didn't solved it.
Any ideas?

Robert-Antonio

--------------------------------------------------------
To obtain my real email address, please remove the
'w' letter from it :)
--------------------------------------------------------

Jul 19 '05 #1
1 3503

"Robert A. T. Kaldy" <ka****@matfyz. cz> wrote in message
news:Pi******** *************** *************** @artax.karlin.m ff.cuni.cz...
Hello,

consider a class with a member function:

template<class schema>
class A
{
schema::t func();
};

template<class schema>
schema::t A<schema>::func ()
{ .... }

The 't' is a type, which will be defined via typedef later, in the schema
class. No, it is not. It is not a type but the object name. If you need to make a
compiler to treat it as a type you shall use "typename" qualifier.
It takes the error
'f': unable to resolve function overload
(I compiled it with VC++ 5.0)

Just a casual remark: I suspect you are going to have a lot of C++ language
problems with this pretty old compiler.

--
With regards,
Michael Kochetkov.
Jul 19 '05 #2

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

Similar topics

6
3347
by: Patrick Kowalzick | last post by:
Dear all, I have a question about default template parameters. I want to have a second template parameter which as a default parameter, but depends on the first one (see below). Is something like that possible? Some workaround? Thank you, Patrick
31
3492
by: nikola | last post by:
Hi all, I was working with a simple function template to find the min of two values. But since I would like the two values to be different (type) I dont know what kind of value (type) it will return. I tried to write something like this: template <class Type1, class Type2, class Type3> Type3 findMin(Type1 x, Type2 y){ return (x < y) ? x : y;
1
1461
by: icedac | last post by:
I have some questions about template and c++ itself. ///////////////////////////////////////////////////////////////////////// q1) see follow c++ code, and compile. it's works only IntelC++8.1 but VC71. Do you know why? Which compiler's activity is C++STANDARD? And I wanna be feed back some explain. :)
5
1518
by: Axter | last post by:
I'm fine tuning a scope_handle class that takes a policy class as the second template. http://code.axter.com/scope_handle.h Please see above link for full understanding of the problem. One thing I don't like about the way the current policy template is setup is that for the ptr_policy class the first template type is different from the template type given to the policy. And on the other policy classes, the template type is the same....
2
2342
by: PengYu.UT | last post by:
I have the following sample program, which can convert function object with 1 argument into function object with 2 arguments. It can also do + between function object of the same type. The last line is very long. I'm wondering if there is any way to suppress it. I can only think of typedef. But I'm not sure whether I can use typedef for the return type. Would you please help me? Please don't be daunted by the length of the code.
1
2356
by: mathieu | last post by:
Hello there, I am playing around with template metaprograming: I am trying to redefines my own types. But I am facing a small issue, where I cannot describe the whole implementation in one single class. Instead I have to separate implementation for binary and ascii in two different classes as I don't know how to use the traits technique for constructors. Any pointers very welcome !
2
3337
by: pagekb | last post by:
Hello, I'm having some difficulty compiling template classes as containers for other template objects. Specifically, I have a hierarchy of template classes that contain each other. Template class B has an instance of template class A, which has some base type T (usually int or double). However, the base type T is important to calculations in B, so I would like to obtain access to the type for further variable declaration within B. ...
19
7921
by: aaragon | last post by:
Hi everyone. A very simple question. I would like to know what is better in terms of performance. I want to use a simple function to obtain the minimum of two values. One way could be using a macro: #define min(a,b) ((a<b)?a:b) I thought that another way could be to use a template function: template <class T> T min<T a, T b>
3
2478
by: IR | last post by:
Hi, I've been trying to do the following (which doesn't compile) : template<class T, class F = Example<T struct Example { F foo(); };
7
2019
by: aaragon | last post by:
Hi everyone, The idea is quite simple: generate a container with random values in it. For that, I decided to create a class that I called RandomContainer that inherits from a container (with default value std::vector<T>). To handle the different ways that the values are randomized, I created a traits class. The problem that I have, is that the function randomize() within the traits class takes different parameters depending on the type...
0
8448
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, 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...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8783
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 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...
1
8552
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7387
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
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...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2773
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.