Hi,
I was attempting to implement partial specialization using VC 2005.
However i cannot get my code to compile :( .. Can you please help me?
template <typename TYPE1>
class myClass<TYPE1, int>
//C2143: syntax error : missing ';' before '<'
//C2059: syntax error : '<'
{//C2143: syntax error : missing ';' before '{'
//error C2447: '{' : missing function header (old-style formal list?)
private:
TYPE1 xUnspecifiedParameter;
int xSpecifiedParameter;
public:
myClass(TYPE1 xUnspecifiedParameter, int xSpecifiedParameter):
xUnspecifiedParameter(xType1),
xSpecifiedParameter(xInt)
{}
};
if i remove <TYPE1, int> from class myClass<TYPE1, int> the compiler
errors go away but instantiating myclass causes errors ...
myClass<int,int> myInstance(2,3);
the compiler complains
error C2977: 'myClass' : too many template arguments
error C2514: 'myClass' : class has no constructors 2 1899
VB wrote: Hi, I was attempting to implement partial specialization using VC 2005. However i cannot get my code to compile :( .. Can you please help me?
Where is the definition of myClass? We need that part to be able to
help you.
template <typename TYPE1> class myClass<TYPE1, int>
This is partial specialization of some previously defined and currently
unknown type.
//C2143: syntax error : missing ';' before '<' //C2059: syntax error : '<' {//C2143: syntax error : missing ';' before '{' //error C2447: '{' : missing function header (old-style formal list?) private: TYPE1 xUnspecifiedParameter; int xSpecifiedParameter; public: myClass(TYPE1 xUnspecifiedParameter, int xSpecifiedParameter): xUnspecifiedParameter(xType1), xSpecifiedParameter(xInt) {}
};
if i remove <TYPE1, int> from class myClass<TYPE1, int> the compiler errors go away but instantiating myclass causes errors ... myClass<int,int> myInstance(2,3); the compiler complains error C2977: 'myClass' : too many template arguments error C2514: 'myClass' : class has no constructors
Noah Roberts wrote:
I read about partial specializations again. Now i understand them
better. I had misinterpreted their usage.
thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Paul MG |
last post by:
Hi
Template partial specialization always seems like a fairly
straightforward concept - until I try to do it :).
I am trying to implement the input sequence type (from Stroustrup
section...
|
by: Dave Theese |
last post by:
Hello all,
I'm trying to get a grasp of the difference between specializing a function
template and overloading it. The example below has a primary template, a
specialization and an overload. ...
|
by: Agent Mulder |
last post by:
Hi group,
I have a problem with partial template specialization. In the code
below I have a template struct Music with one method, play(),
and three kinds of music, Jazz, Funk and Bach. When I...
|
by: SainTiss |
last post by:
Hi,
From what I've read in several places, it seems that explicit specialization
of member functions of class templates is allowed, but partial
specialization isn't:
template<class T, class...
|
by: Shekhar |
last post by:
template<typename T> struct A{}; //line 1
template<typename T> struct B{}; //line 2
template<typename T> struct B<A<T> > {}; //line 3: partial
specialization of B
VC6.0 compiler results for the...
|
by: Matt Taylor |
last post by:
I'm trying to write an x86 assembler in C++ for use in a debugger. What I'd
like do is to use template specialization to prevent invalid combinations
from compiling. Thus one could not accidentally...
|
by: WittyGuy |
last post by:
Hi,
What is the major difference between function overloading and function
templates?
Thanks!
http://www.gotw.ca/resources/clcm.htm for info about ]
|
by: Kalle Rutanen |
last post by:
Here is a short code. I can't see why the template specialization does
not work (vsnet2003)? Does the standard allow these kind of
specializations?
template <int i>
class B {};
template...
|
by: Greg |
last post by:
Hi,
I would like to specify behavior of a class member relatively to
template implemetation. It works in usual cases but it seems to fail
with to templates when one of the two is specified...
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |