|
|
I'm using a long long variable with swprintf, however swprintf is unable to understand long long and returning zero.
wchar_t[20];
long long var = 500000;
swprintf(t, L"%i", var);
MessageBox(NULL, t, L"Output", NULL);
tried %i and %d
any advice for work fix solution or a work around! i would be very thankful.
|
|
|
|
|
try %lld, that's what most C runtimes use, I don't see it in the MS doco, but it might just work...
modified on Sunday, April 25, 2010 2:59 PM
|
|
|
|
|
|
Not portable, "I64" formats a _int64, while "ll" formats a long long, which is AT LEAST 64 bits long. Haven't yet met a platform where they differ though
|
|
|
|
|
OP said nothing about "portable"
|
|
|
|
|
See the MSDN reference here[^] for details of format specifiers. Your format string uses "%i " which is for normal integer.
It's time for a new signature.
|
|
|
|
|
How do you format numbers with commas?
10
100
1,000
10,000
100,000
1,000,000
10,000,000
100,000,000
1,000,000,000
I found the context for doing that somewhere before, but I'm unable to find anywhere!
|
|
|
|
|
|
Hi, I'm a student and now I'm working on a project in computer vision field. I need to detect the changes between two images (captured at different times, at the same position ), and the problems are noises and illumination variations in these images. I've read many paper with complex algorithms to solve these problems, but it's very difficult to implement them in programming language (mine is C++). Could you suggest me how to solve these problem, or point me to an open source program which does this task ?
Thanks and best regards !
|
|
|
|
|
Here is a more logic thinking solution than actual guidance.
I'm sure you know char table[x][y], I believe you can use it with the Bitmap data type. I don't know the relevant declaration for it. You create a table for the first image and a second table containing the second image. You can then select which to use as reference and then calculate based on pixel [1][1] for the second picture based on the difference for the reference picture. Hope that helped!
If you can share those papers, I have interest to dip my hands on something similar.
|
|
|
|
|
|
There will be slight changes in the images even when the target object hasn't changed. The key problem is determining if the changes are enough to conclude the target object has changed.
The first step is to obtain sample data. Capture repeated images of the unchanged object (under different conditions, e.g. day/night). Then capture images of the MINIMUM change in the target object you want to detect.
The next step is to analyze the variation among the images of the unchanged object, and the differences between the images of the changed/unchanged object.
In the easiest case, you'll find a simple threshold that will distinguish between the changed and unchanged cases. It's harder if the noise/illumination differences among the unchanged images exceed the differences between changed/unchanged objects. In this case, you'll need a more complex algorithm.
Two things to look at: 1. Total number of pixels that have changed, and 2. Total number of pixels that have changed by more than a given threshold.
|
|
|
|
|
So, Trying to make a 5 card draw poker game using C, and I've come across a hurdle. The following code is randomly choosing cards correctly, but when I try to change them from their deck number to their card, they all come out as the same card. Not sure what is happening, but if you run the program, I put cout statements in to show how the numbers are random.
#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
#include <stdlib.h>
using namespace std;
int main()
{
int cardNum1;
int cardNum2;
int cardNum3;
int cardNum4;
int cardNum5;
int cardNum6;
int cardNum7;
int cardNum8;
int cardNum9;
string card1;
string card2;
string card3;
string card4;
string card5;
string card6;
string card7;
string card8;
string card9;
string suit1;
string suit2;
string suit3;
string suit4;
string suit5;
string suit6;
string suit7;
string suit8;
string suit9;
srand(unsigned(time(NULL)));
cardNum1 = (rand()%51 + 1);
cout << cardNum1 << endl;
do
{
cardNum2 = (rand()%51 + 1);
}
while(cardNum2 == cardNum1);
cout << cardNum2 << endl;
do
{
cardNum3 = (rand()%51 + 1);
}
while(cardNum3 == (cardNum1 || cardNum2));
cout << cardNum3 << endl;
do
{
cardNum4 = (rand()%51 + 1);
}
while(cardNum4 == (cardNum1 || cardNum2 || cardNum3));
cout << cardNum4 << endl;
do
{
cardNum5 = (rand()%51 + 1);
}
while(cardNum5 == (cardNum1 || cardNum2 || cardNum3 || cardNum4));
cout << cardNum5 << endl;
do
{
cardNum6 = (rand()%51 +1);
}
while(cardNum6 == (cardNum1 || cardNum2 || cardNum3 || cardNum4 || cardNum5));
cout << cardNum6 << endl;
do
{
cardNum7 = (rand()%51 + 1);
}
while(cardNum7 == (cardNum1 || cardNum2 || cardNum3 || cardNum4 || cardNum5 || cardNum6));
cout << cardNum7 << endl;
do
{
cardNum8 = (rand()%51 + 1);
}
while(cardNum8 == (cardNum1 || cardNum2 || cardNum3 || cardNum4 || cardNum5 || cardNum6 || cardNum7));
cout << cardNum8 << endl;
do
{
cardNum9 = (rand()%51 + 1);
}
while(cardNum9 == (cardNum1 || cardNum2 || cardNum3 || cardNum4 || cardNum5 || cardNum6 || cardNum7 || cardNum8));
cout << cardNum9 << endl;
cout << cardNum1 << ' ' << cardNum2 << ' ' << cardNum3 << ' ' << cardNum4 << ' ' << cardNum5 << endl;
cout << cardNum6 << ' ' << cardNum7 << ' ' << cardNum8 << ' ' << cardNum9 << endl;
if (cardNum1 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
{
suit1 = "Hearts";
}
else if (cardNum1 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
{
suit1 = "Spades";
}
else if (cardNum1 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
{
suit1 = "Diamonds";
}
else
{
suit1 = "Clubs";
}
if(cardNum1 == 1 || 14 || 27 || 40)
card1 = "Ace";
else if(cardNum1 == 2 || 15 || 28 || 41)
card1 = "Two";
else if(cardNum1 == 3 || 16 || 29 || 42)
card1 = "Three";
else if(cardNum1 == 4 || 17 || 30 || 43)
card1 = "Four";
else if(cardNum1 == 5 || 18 || 31 || 44)
card1 = "Five";
else if(cardNum1 == 6 || 19 || 32 || 45)
card1 = "Six";
else if(cardNum1 == 7 || 20 || 33 || 46)
card1 = "Seven";
else if(cardNum1 == 8 || 21 || 34 || 47)
card1 = "Eight";
else if(cardNum1 == 9 || 22 || 35 || 48)
card1 = "Nine";
else if(cardNum1 == 10 || 23 || 36 || 49)
card1 = "Ten";
else if(cardNum1 == 11 || 24 || 37 || 50)
card1 = "Jack";
else if(cardNum1 == 12 || 25 || 38 || 51)
card1 = "Queen";
else
card1 = "King";
if (cardNum2 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit2 = "Hearts";
else if (cardNum2 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit2 = "Spades";
else if (cardNum2 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit2 = "Diamonds";
else
suit2 = "Clubs";
if(cardNum2 == 1 || 14 || 27 || 40)
card2 = "Ace";
else if(cardNum2 == 2 || 15 || 28 || 41)
card2 = "Two";
else if(cardNum2 == 3 || 16 || 29 || 42)
card2 = "Three";
else if(cardNum2 == 4 || 17 || 30 || 43)
card2 = "Four";
else if(cardNum2 == 5 || 18 || 31 || 44)
card2 = "Five";
else if(cardNum2 == 6 || 19 || 32 || 45)
card2 = "Six";
else if(cardNum2 == 7 || 20 || 33 || 46)
card2 = "Seven";
else if(cardNum2 == 8 || 21 || 34 || 47)
card2 = "Eight";
else if(cardNum2 == 9 || 22 || 35 || 48)
card2 = "Nine";
else if(cardNum2 == 10 || 23 || 36 || 49)
card2 = "Ten";
else if(cardNum2 == 11 || 24 || 37 || 50)
card2 = "Jack";
else if(cardNum2 == 12 || 25 || 38 || 51)
card2 = "Queen";
else
card2 = "King";
if (cardNum3 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit3 = "Hearts";
else if (cardNum3 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit3 = "Spades";
else if (cardNum3 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit3 = "Diamonds";
else
suit3 = "Clubs";
if(cardNum3 == 1 || 14 || 27 || 40)
card3 = "Ace";
else if(cardNum3 == 2 || 15 || 28 || 41)
card3 = "Two";
else if(cardNum3 == 3 || 16 || 29 || 42)
card3 = "Three";
else if(cardNum3 == 4 || 17 || 30 || 43)
card3 = "Four";
else if(cardNum3 == 5 || 18 || 31 || 44)
card3 = "Five";
else if(cardNum3 == 6 || 19 || 32 || 45)
card3 = "Six";
else if(cardNum3 == 7 || 20 || 33 || 46)
card3 = "Seven";
else if(cardNum3 == 8 || 21 || 34 || 47)
card3 = "Eight";
else if(cardNum3 == 9 || 22 || 35 || 48)
card3 = "Nine";
else if(cardNum3 == 10 || 23 || 36 || 49)
card3 = "Ten";
else if(cardNum3 == 11 || 24 || 37 || 50)
card3 = "Jack";
else if(cardNum3 == 12 || 25 || 38 || 51)
card3 = "Queen";
else
card3 = "King";
if (cardNum4 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit4 = "Hearts";
else if (cardNum4 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit4 = "Spades";
else if (cardNum4 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit4 = "Diamonds";
else
suit4 = "Clubs";
if(cardNum4 == 1 || 14 || 27 || 40)
card4 = "Ace";
else if(cardNum4 == 2 || 15 || 28 || 41)
card4 = "Two";
else if(cardNum4 == 3 || 16 || 29 || 42)
card4 = "Three";
else if(cardNum4 == 4 || 17 || 30 || 43)
card4 = "Four";
else if(cardNum4 == 5 || 18 || 31 || 44)
card4 = "Five";
else if(cardNum4 == 6 || 19 || 32 || 45)
card4 = "Six";
else if(cardNum4 == 7 || 20 || 33 || 46)
card4 = "Seven";
else if(cardNum4 == 8 || 21 || 34 || 47)
card4 = "Eight";
else if(cardNum4 == 9 || 22 || 35 || 48)
card4 = "Nine";
else if(cardNum4 == 10 || 23 || 36 || 49)
card4 = "Ten";
else if(cardNum4 == 11 || 24 || 37 || 50)
card4 = "Jack";
else if(cardNum4 == 12 || 25 || 38 || 51)
card4 = "Queen";
else
card4 = "King";
if (cardNum5 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit5 = "Hearts";
else if (cardNum5 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit5 = "Spades";
else if (cardNum5 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit5 = "Diamonds";
else
suit5 = "Clubs";
if(cardNum5 == 1 || 14 || 27 || 40)
card5 = "Ace";
else if(cardNum5 == 2 || 15 || 28 || 41)
card5 = "Two";
else if(cardNum5 == 3 || 16 || 29 || 42)
card5 = "Three";
else if(cardNum5 == 4 || 17 || 30 || 43)
card5 = "Four";
else if(cardNum5 == 5 || 18 || 31 || 44)
card5 = "Five";
else if(cardNum5 == 6 || 19 || 32 || 45)
card5 = "Six";
else if(cardNum5 == 7 || 20 || 33 || 46)
card5 = "Seven";
else if(cardNum5 == 8 || 21 || 34 || 47)
card5 = "Eight";
else if(cardNum5 == 9 || 22 || 35 || 48)
card5 = "Nine";
else if(cardNum5 == 10 || 23 || 36 || 49)
card5 = "Ten";
else if(cardNum5 == 11 || 24 || 37 || 50)
card5 = "Jack";
else if(cardNum5 == 12 || 25 || 38 || 51)
card5 = "Queen";
else
card5 = "King";
if (cardNum6 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit6 = "Hearts";
else if (cardNum6 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit6 = "Spades";
else if (cardNum6 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit6 = "Diamonds";
else
suit6 = "Clubs";
if(cardNum6 == 1 || 14 || 27 || 40)
card6 = "Ace";
else if(cardNum6 == 2 || 15 || 28 || 41)
card6 = "Two";
else if(cardNum6 == 3 || 16 || 29 || 42)
card6 = "Three";
else if(cardNum6 == 4 || 17 || 30 || 43)
card6 = "Four";
else if(cardNum6 == 5 || 18 || 31 || 44)
card6 = "Five";
else if(cardNum6 == 6 || 19 || 32 || 45)
card6 = "Six";
else if(cardNum6 == 7 || 20 || 33 || 46)
card6 = "Seven";
else if(cardNum6 == 8 || 21 || 34 || 47)
card6 = "Eight";
else if(cardNum6 == 9 || 22 || 35 || 48)
card6 = "Nine";
else if(cardNum6 == 10 || 23 || 36 || 49)
card6 = "Ten";
else if(cardNum6 == 11 || 24 || 37 || 50)
card6 = "Jack";
else if(cardNum6 == 12 || 25 || 38 || 51)
card6 = "Queen";
else
card6 = "King";
if (cardNum7 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit7 = "Hearts";
else if (cardNum7 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit7 = "Spades";
else if (cardNum7 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit7 = "Diamonds";
else
suit7 = "Clubs";
if(cardNum7 == 1 || 14 || 27 || 40)
card7 = "Ace";
else if(cardNum7 == 2 || 15 || 28 || 41)
card7 = "Two";
else if(cardNum7 == 3 || 16 || 29 || 42)
card7 = "Three";
else if(cardNum7 == 4 || 17 || 30 || 43)
card7 = "Four";
else if(cardNum7 == 5 || 18 || 31 || 44)
card7 = "Five";
else if(cardNum7 == 6 || 19 || 32 || 45)
card7 = "Six";
else if(cardNum7 == 7 || 20 || 33 || 46)
card7 = "Seven";
else if(cardNum7 == 8 || 21 || 34 || 47)
card7 = "Eight";
else if(cardNum7 == 9 || 22 || 35 || 48)
card7 = "Nine";
else if(cardNum7 == 10 || 23 || 36 || 49)
card7 = "Ten";
else if(cardNum7 == 11 || 24 || 37 || 50)
card7 = "Jack";
else if(cardNum7 == 12 || 25 || 38 || 51)
card7 = "Queen";
else
card7 = "King";
if (cardNum8 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit8 = "Hearts";
else if (cardNum8 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit8 = "Spades";
else if (cardNum8 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit8 = "Diamonds";
else
suit8 = "Clubs";
if(cardNum8 == 1 || 14 || 27 || 40)
card8 = "Ace";
else if(cardNum8 == 2 || 15 || 28 || 41)
card8 = "Two";
else if(cardNum8 == 3 || 16 || 29 || 42)
card8 = "Three";
else if(cardNum8 == 4 || 17 || 30 || 43)
card8 = "Four";
else if(cardNum8 == 5 || 18 || 31 || 44)
card8 = "Five";
else if(cardNum8 == 6 || 19 || 32 || 45)
card8 = "Six";
else if(cardNum8 == 7 || 20 || 33 || 46)
card8 = "Seven";
else if(cardNum8 == 8 || 21 || 34 || 47)
card8 = "Eight";
else if(cardNum8 == 9 || 22 || 35 || 48)
card8 = "Nine";
else if(cardNum8 == 10 || 23 || 36 || 49)
card8 = "Ten";
else if(cardNum8 == 11 || 24 || 37 || 50)
card8 = "Jack";
else if(cardNum8 == 12 || 25 || 38 || 51)
card8 = "Queen";
else
card8 = "King";
if (cardNum9 == 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13)
suit9 = "Hearts";
else if (cardNum9 == 14 || 15 || 16 || 17 || 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26)
suit9 = "Spades";
else if (cardNum9 == 27 || 28 || 29 || 30 || 31 || 32 || 33 || 34 || 35 || 36 || 37 || 38 || 39)
suit9 = "Diamonds";
else
suit9 = "Clubs";
if(cardNum9 == 1 || 14 || 27 || 40)
card9 = "Ace";
else if(cardNum9 == 2 || 15 || 28 || 41)
card9 = "Two";
else if(cardNum9 == 3 || 16 || 29 || 42)
card9 = "Three";
else if(cardNum9 == 4 || 17 || 30 || 43)
card9 = "Four";
else if(cardNum9 == 5 || 18 || 31 || 44)
card9 = "Five";
else if(cardNum9 == 6 || 19 || 32 || 45)
card9 = "Six";
else if(cardNum9 == 7 || 20 || 33 || 46)
card9 = "Seven";
else if(cardNum9 == 8 || 21 || 34 || 47)
card9 = "Eight";
else if(cardNum9 == 9 || 22 || 35 || 48)
card9 = "Nine";
else if(cardNum9 == 10 || 23 || 36 || 49)
card9 = "Ten";
else if(cardNum9 == 11 || 24 || 37 || 50)
card9 = "Jack";
else if(cardNum9 == 12 || 25 || 38 || 51)
card9 = "Queen";
else
card9 = "King";
cout << "1. " << card1 << " of " << suit1 << endl;
cout << "2. " << card2 << " of " << suit2 << endl;
cout << "3. " << card3 << " of " << suit3 << endl;
cout << "4. " << card4 << " of " << suit4 << endl;
cout << "5. " << card5 << " of " << suit5 << endl;
cout << "6. " << card6 << " of " << suit6 << endl;
cout << "7. " << card7 << " of " << suit7 << endl;
cout << "8. " << card8 << " of " << suit8 << endl;
cout << "9. " << card9 << " of " << suit9 << endl;
cin.get();
cin.get();
return 0;
}
|
|
|
|
|
Sorry for it being so long. First programming class, so I can only use what I know.
The includes didn't copy correctly, so here they are.
#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
#include <stdlib.h>
|
|
|
|
|
Hi,
probably lots of problems in your code; I didn't look at it in any detail as there is a lot of it and it is badly formatted. Next time use PRE tags so it gets to preserve its original formatting and indentation, and gets shown in a non-proportional font, with syntax coloring.
if(cardNum9 == 8 || 21 || 34 || 47) is not what you want; you mean
if(cardNum9 == 8 || cardNum9 == 21 || cardNum9 == 34 || cardNum9 == 47)
which you probably could write as just if((cardNum9 % 13) == 8)
Whay you wrote is ORing all the numbers, treating them as booleans, hence the result is always 1 (unless all your numbers were 0).
Strong suggestion: if you are familiar with arrays, start using them right now. You can do what you have with one fifth of the code you have now, and less code means less trouble and fewer bugs. You will waste a lot of time by not using arrays!
and why is it %51 and not %52???????????????
|
|
|
|
|
Thanks for the quick reply, Luc.
I'll plug the new way of doing the numbers into my code in a little while, hopefully they will work, but my wrists are starting to cramp from all the playing in the code I've been doing.
The class I am in doesn't start array's until next week, so that's why I haven't used any yet, but I do plan to use them. I just wanted to get a jump-start on my final project and see what I could do with what I know.
And I have it as %51+1 instead of %52, because doesn't %52 give you all the numbers from 0-52? I don't need 0 so by adding the +1 to %51, I make it 1-52.
|
|
|
|
|
as %N returns the remainder after division by N, what do you think the largest value of %N could be?
without arrays, make sure to consider using a lot of modulo operators! I already gave you an example.
|
|
|
|
|
just a note.
the % operator has a lower precedence than the + operator. so you code is really doing this: rand() % 52 . that is, the addition (51 + 1) happens before the %.
this might be closer to what you want: (rand() % 51) + 1
don't know if it will solve your problem, tho.
|
|
|
|
|
Have also a look at my tip: "Random extraction of 5 cards from a deck" to avoid unnecessary verification steps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I wrote a template class which can accept various data types (I had different kind of data to handle)
All the data type I used with this template-class, are structures with common parameters.
Now I need to write a common code to all classes (I was thinking of a function with his own class) to use these "common" parameters.
The solutions I thought are:
1) Passing a void* pointer to the function and select the appropriate code for the datatype:
void Function( void *pointer_to_custom_data, ENUM_DATA_TYPE)
{
if(ENUM_DATA_TYPE == DATA_TYPE1)
// specific code for type1..
else if (ENUM_DATA_TYPE == DATA_TYPE2)
// specific code for type2..
...
}
2) Overloading in some way this function (don't know how though) so it recognize the type used and uses the specific code
Any better idea or suggestion on how to implement these?
---
|
|
|
|
|
I'm not sure i completely understand your problem, but the first thought that comes to my mind is: why don't you have a common base class for your structures that contains the common "parameters" you are talking about, then you can make a method that takes a pointer/reference to this base class and does with the parameters what it should. Or do you mean that you have to do different things depending on the type of struct? Then use a virtual function declared in the base class and implement it according to your needs in all the subclasses. Am i misunderstanding you?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
You should, if possible, make the function part of the template class, thus ensuring type safety throughout. See the MSDN documentation on Templates[^] for more information.
It's time for a new signature.
|
|
|
|
|
This looks likes bad design to me. Template class should not be explicitly aware of the types it can be used with. It can define the requirements in the types but that is all.
In your case it looks like better option is to use inheritance instead of template class. Unless of course you have presented a simplified picture.
I will suggest you inherit the structures from a common base class. This base class will contain common parameters and a pure virtual function. Inherited structures will override this function providing the type specific functionality.
-Saurabh
|
|
|
|
|
If you want type specific code, you do not write a template class.
In some cases, for template classes you need a special implementation for a certain type.
In these cases you can do template specialization.
Assume you have a template class called Math -
template<typename T>
class Math
{
};
You may need special implementation for some data type like complex.
In this case you can specialize the template class for the complex data type.
template<>
class Math<complex>
{
};
|
|
|
|