473,387 Members | 1,530 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 probleme

Hi,

The following code compiles on Unix but refuse to do so with devstudio6

can anyone help me to get it right ? (ie for visual studio)
template <class T> class AutoPtr
{
public:
/** Default constructor. */
AutoPtr(T* p = 0);

/** Copy contructing an AutoPtr from another AutoPtr causes the old
one
* to be released from destruction duty. */
AutoPtr(const AutoPtr &a);

/** Copy contructing an AutoPtr from a pointer with a different element
type. */
template<class T1> AutoPtr(const AutoPtr<T1> &a);
}

devstudio says: member function already defined or declared
on the last constructor

thanks

yomgui
Jul 23 '05 #1
3 1371
On 2005-03-28, yomgui <no*@valid.com> wrote:
Hi,

The following code compiles on Unix but refuse to do so with devstudio6

can anyone help me to get it right ? (ie for visual studio)
template <class T> class AutoPtr
{
public:
/** Default constructor. */
AutoPtr(T* p = 0);

/** Copy contructing an AutoPtr from another AutoPtr causes the old
one
* to be released from destruction duty. */
AutoPtr(const AutoPtr &a);

/** Copy contructing an AutoPtr from a pointer with a different element
type. */
template<class T1> AutoPtr(const AutoPtr<T1> &a);
}

devstudio says: member function already defined or declared
on the last constructor


Looks like an issue with the compiler -- the parameterized constructor is
*not* a copy constructor.

Here's a question for you -- what is the output of this code on your compiler ?
The template constructor should not be called on copy -- the compiler should
still create one.

/*
template construct ...
conversion construct called!
calling copy construct ...
*/

#include <iostream>

class X {
public:

template <typename T> X(const T& ) {
std::cout << "conversion construct called!" << std::endl;
}
};
int main()
{
std::cout << "template construct ... " << std::endl;
X x(3);
std::cout << "calling copy construct ... " << std::endl;
X y(x);
}
Cheers,
--
Donovan Rebbechi
http://pegasus.rutgers.edu/~elflord/
Jul 23 '05 #2
yomgui wrote:
The following code compiles on Unix but refuse to do so with devstudio6

can anyone help me to get it right ? (ie for visual studio)
You will have to upgrade your compiler to 7.1 or 8.0 Beta in order to
make it work. VC++ v6 is notoriously bad with member templates.
[...]

Jul 23 '05 #3
I've tried your test,
this is also my result:
template construct ...
conversion construct called!
calling copy construct ...


yomgui

Jul 23 '05 #4

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

Similar topics

1
by: cyril | last post by:
Bonjour à tous, j'utilise Apache php et mysql sans probleme, j'ai voulu passer pour des raisons pro sur IIS PHP MS SQL.IIS et PHP fonctionne bien, j ai decommenté la ligne pour ms sql, copier la...
2
by: grigoo | last post by:
bonjour a tous je me presente a vous::: greg dit le grigoo sur le web ,,etudiant en bioinformatique a montreal et jusqu au cou dans notre language prefere....java. et biojava.. et je suis en un...
0
by: Jan Metzger | last post by:
Probleme mit JOIN und COUNT, da ich sehr experimentierfreudig bin, versuche ich von zeit zu zeit neue Tabellen und abfragen-konstrukte für meine Community... da ich mir alles was ich über PHP...
2
by: loki | last post by:
hello, when i do ..... set xmlhttp = CreateObject("WinHTTP.WinHTTPRequest.5.1") ...... StrXmlhttpResponseText = xmlhttp.responseText StrXmlhttpResponseText = replace(StrXmlhttpResponseText,...
31
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...
1
by: Badboy36 | last post by:
Hello user from googlegroups, i made a microsoft access database with front and backend. i created the backend in microsoft access97. for the frontend i made two versions (one for microsoft...
0
by: fishomen | last post by:
hello i have probome with my seesion_start. it make the browser (ie6) to make like it is loading, allthought it finish to load. it shoe that it still loading the page with the green status bar. ...
1
by: Michael M. | last post by:
off topic question: Forum for computer science / Informatik-Probleme? Is there a forum for computer science problems? (web or newsgroup etc.) For example, need to solve intersection problems. etc.
2
by: Winkl | last post by:
Hallo zusammen, ich bin gerade dabei meine 1. Homepage unter ASP.NET (VB) zu machen. Habe bis jetzt nur Erfahrung unter Access+VBA. Dabei sind folgende Probleme/Fragen aufgetreten: 1. Gibt es...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.