Click here to Skip to main content
15,890,438 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: calculation error Pin
Luc Pattyn14-Oct-09 13:41
sitebuilderLuc Pattyn14-Oct-09 13:41 
GeneralRe: calculation error Pin
kbury15-Oct-09 5:07
kbury15-Oct-09 5:07 
GeneralRe: calculation error Pin
Luc Pattyn15-Oct-09 5:38
sitebuilderLuc Pattyn15-Oct-09 5:38 
QuestionHow to convert the vbscript to c++ using adsi Pin
raja 414-Oct-09 4:59
raja 414-Oct-09 4:59 
AnswerRe: How to convert the vbscript to c++ using adsi Pin
David Crow15-Oct-09 3:15
David Crow15-Oct-09 3:15 
QuestionEnabling and Disadbling Toolbar Buttons. Pin
hariakuthota14-Oct-09 4:43
hariakuthota14-Oct-09 4:43 
AnswerRe: Enabling and Disadbling Toolbar Buttons. Pin
CPallini14-Oct-09 5:27
mveCPallini14-Oct-09 5:27 
QuestionProblem in C++ Template definition Pin
gourishsio14-Oct-09 4:32
gourishsio14-Oct-09 4:32 
hi,

I have a defined a function template as follows.
template<typename T, typename Function, typename K>
std::vector<K> find( std::vector<T> &a, Function _predicate )
{
std::vector<K> b(a.size());
//... some Code ..//
return(b);
}

which gives a compile error when i try to compile it using VC++
stating that it cannot deduce argument for parameter K.

I have attached the sample code below,
any suggestions from anyone?
Thank you

/********* File main.cpp **********/
#include <iostream>
#include "prog.h"

int main()
{
std::vector<int> a(10);
for( int i = 0; i < 10; i++)
{

a[i] = i;
}

std::vector<int> b = find( a, is_true<int>() );
for( int i = 0; i < 10; i++)
{

cout << "Value " << i << " : " << b[i] << endl;
}
}

#indef PROG_H_INCLUDED
#define PROG_H_INCLUDED

#include <vector>

//Function Predicate to check whether a value is true
template <typename T>
class is_true
{
public:
is_true()
{}

bool operator() (const T &element) const
{
if( element )
{
return true;
}
else
{
return false;
}
}
};

//Function Predicate to check whether a value is true
template <typename T>
class is_false
{
public:
is_false()
{}

bool operator() (const T &element) const
{
if( !element )
{
return true;
}
else
{
return false;
}
}
};


template<typename T, typename Function, typename K>
std::vector<K> find( std::vector<T> &a, Function _predicate )
{
std::vector<K> b(a.size());
for( int i = 0; i < a.size(); i++ )
{
if( _predicate(a[i]) )
{
b[i] = K(a[i]);
}
}
return(b);
}

#endif // PROG_H_INCLUDED
AnswerRe: Problem in C++ Template definition Pin
CPallini14-Oct-09 5:24
mveCPallini14-Oct-09 5:24 
AnswerRe: Problem in C++ Template definition [modified] Pin
Stuart Dootson14-Oct-09 6:19
professionalStuart Dootson14-Oct-09 6:19 
QuestionCreating a Status Bar in DialogBased Application Pin
Hari_1614-Oct-09 3:49
Hari_1614-Oct-09 3:49 
AnswerRe: Creating a Status Bar in DialogBased Application Pin
Roger Stoltz14-Oct-09 4:47
Roger Stoltz14-Oct-09 4:47 
AnswerRe: Creating a Status Bar in DialogBased Application Pin
David Crow14-Oct-09 7:52
David Crow14-Oct-09 7:52 
GeneralRe: Creating a Status Bar in DialogBased Application Pin
Hari_1614-Oct-09 18:01
Hari_1614-Oct-09 18:01 
GeneralRe: Creating a Status Bar in DialogBased Application Pin
David Crow15-Oct-09 3:09
David Crow15-Oct-09 3:09 
QuestionHow to convert real to binary Pin
Aljaz11114-Oct-09 3:09
Aljaz11114-Oct-09 3:09 
AnswerRe: How to convert real to binary Pin
Iain Clarke, Warrior Programmer14-Oct-09 3:22
Iain Clarke, Warrior Programmer14-Oct-09 3:22 
AnswerRe: How to convert real to binary Pin
Cedric Moonen14-Oct-09 4:18
Cedric Moonen14-Oct-09 4:18 
AnswerRe: How to convert real to binary Pin
CPallini14-Oct-09 5:05
mveCPallini14-Oct-09 5:05 
GeneralRe: How to convert real to binary Pin
Aljaz11114-Oct-09 6:26
Aljaz11114-Oct-09 6:26 
GeneralRe: How to convert real to binary Pin
Ozer Karaagac14-Oct-09 15:54
professionalOzer Karaagac14-Oct-09 15:54 
GeneralRe: How to convert real to binary Pin
Luc Pattyn14-Oct-09 16:18
sitebuilderLuc Pattyn14-Oct-09 16:18 
GeneralRe: How to convert real to binary Pin
Patcher3214-Oct-09 17:59
Patcher3214-Oct-09 17:59 
QuestionOpen an associated file using doubleclick while application is running Pin
Erik14-Oct-09 2:22
Erik14-Oct-09 2:22 
QuestionRe: Open an associated file using doubleclick while application is running Pin
David Crow14-Oct-09 2:27
David Crow14-Oct-09 2:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.