C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 12th, 2014, 02:44 PM
josebins josebins is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2014
Posts: 1 josebins User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 50 sec
Reputation Power: 0
General - My specialization of a template function is not found

Hi,

I have a problem with a template specialization which was working under Visual C++ Compiler but doesnt work under the GCC compiler. I would be very grateful if someone can help me.

I have the folowing declarations:

--------------------------------------------
File File1.h //Declaration of function f1


#include "File2.h"
template <class Td, class Tk = int> class A {
public:
char * f1(int i, int t = 0);
protected:
Td data;
};
template <class Td, class Tk> char * A<Td, Tk>::f1(int p, int t) {
char * strdata = ::f1(data);
}

------------------------------------------------
File File2.h // Function f1 with one parameter



template <class T> char * f1(T dt) {
...
}
char * f1(char * dt);

---------------------------------------------------------
File File3.h // specialization of function f1 for B

#include "FIle1.h"
struct B {
int x1;
char * x2;
};
char * f1(B);

------------------------------------------------
File File3.cpp // specialization of f1 for B and
// call that gives problem


#include "File3.h"

char * f1(B dt){ ... };

A<B,char*> x;

x->f1(3,5);

------------------------------------------------

the call for function A<B,char*>::f1(int,int) on file 3 is ok
but the cal inside it ::f1(B) (on file 1) tries to call the definition from File 2, instead of the one in file 3. And if I remove the definition on file 2 it gives an error because it can not find the definition on file 3. It works as if the definition on file 3 doesnt exists.
That same code used to work on other compilers.
Can someone helpme?

Thanks

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - My specialization of a template function is not found


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap