473,770 Members | 1,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Template Instantiation and member templates.

I have something like this.

typedef enum TYPES{ X =0, Y,
Z,
MAX};

template <typename T>
class A
{
public:
typedef T obj;

A(){ }
~A() { }
template < int N>
void Open();
template < int N>
void Close();
private:
obj Object;
};

then I have

template<>
A<SomePreDefine dObject>::A()
{
// call member function of SomePreDefinedO bject
}

template<>
template<int N>
A<SomePreDefine dObject>::Open( )
{
ASSERT(N < MAX);
// call member function of SomePreDefinedO bject

}

template<>
template<int N>
A<SomePreDefine dObject>::Close ()
{
ASSERT(N < MAX);
// call member function of SomePreDefinedO bject
}
template<>
template<>
A<SomePreDefine dObject>::Open< MAX>()
{
// call member function of SomePreDefinedO bject
}

template<>
template<>
A<SomePreDefine dObject>::Close <MAX>()
{
// call member function of SomePreDefinedO bject
}

now in main I have

main()
{
A<SomePreDefine dObject> O;

O.Lock<MAX>; //everything is fine //line 1

O.Lock<X>; // I get linker error // Line 2

}

Anyone knows why I could be getting linker error for Line 2 whch says
Lock and Unlock not found? I have the memner template defined for all
values except MAX and then for MAX it is specialized.

Thanks.

Jan 27 '06 #1
1 1667
am******@gmail. com wrote:
I have something like this.

[...]

now in main I have

[...]

Anyone knows why I could be getting linker error for Line 2 whch says
Lock and Unlock not found? I have the memner template defined for all
values except MAX and then for MAX it is specialized.


Please post _real_ code with which you have troubles. Read FAQ section 5.

V
Jan 27 '06 #2

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

Similar topics

6
2196
by: Dmitry Epstein | last post by:
Here is an example of a problem, which I tried to reduce to its bare essentials: // begin test1.cpp class E { public: template<class T> static void f(); }; template<class T> void E::f() {}
5
288
by: Gonçalo Rodrigues | last post by:
Hi all, Sorry to bother you guys again with a template question but I'm really trying to understand them and there's some piece of info that I'm missing. I'm sure I'm being really dumb here so, please bear with me. I've reduced my problem to the following: Remark: the example below is just to highlight my problems with templates. I know very well that there are already ways of doing what the example tries to do (for example, with the...
3
8257
by: Patrick Guio | last post by:
Hi, I have trouble to compile the following piece of code with g++3.4 but not with earlier version // Foo.h template<typename T> class Foo { public:
5
6589
by: Levent | last post by:
Hi, Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1): #include <iostream> template<class T, unsigned N> struct Foo { void func(); }; template<class T, unsigned N>
3
2737
by: sks | last post by:
Hello all Is the usage of extern keyword valid for telling the compiler to NOT instantiate a template and to link it from an another binary? For example: Suppose module A's binary contains a template class called "myTemplate", for which there is an instantiation for 'int' type. Now suppose a class in module B binary wants to use this template
5
1747
by: lobequadrat | last post by:
Hello, I am trying to get the following code work (unfortunately not mine ... :( ) template <class Tclass Test { public: class ELEM;
8
1950
by: mattias.nissler | last post by:
Hi! Here is a problem I ran into at work. The following example doesn't compile on gcc-4.1: struct cons_end {}; template<typename U,typename Vstruct cons { U elem; V tail;
2
2606
by: aitrob | last post by:
Hi, I have a problem concerning templates/inheritance. I have a code that compiles fine with g++ 4.0.1 (Apple version), but gives a lot of errors with Intel C++ 10.1 (Mac OS X). I'm not sure if I'm doing something wrong and g++ just doesn't notice, or if the people at Intel are doing something weird... What am I trying to do? I'm trying to implement a template class that inherits from the Blitz++ array library #include <blitz/array.h>...
5
1759
by: emboss | last post by:
If templates worked how I would like them to work, I'd be able to do the following: template <int N> class A { private: int X; public: template <int M> void foo(const A<M> &Src) { X = Src.X; }
11
1412
by: Juha Nieminen | last post by:
I'm writing an STL-style data container, and this problem is puzzling me. The following code should demonstrate the problem: //---------------------------------------------------------- #include <iostream> #include <list> template<typename T> class MyClass {
0
9618
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...
1
10038
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
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.