Click here to Skip to main content
15,914,780 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: vector of doubles (division) Pin
CPallini27-May-10 10:11
mveCPallini27-May-10 10:11 
AnswerRe: vector of doubles (division) Pin
Aescleal27-May-10 12:38
Aescleal27-May-10 12:38 
GeneralRe: vector of doubles (division) Pin
Stephen Hewitt27-May-10 20:15
Stephen Hewitt27-May-10 20:15 
GeneralRe: vector of doubles (division) Pin
Aescleal27-May-10 20:52
Aescleal27-May-10 20:52 
GeneralRe: vector of doubles (division) Pin
Stephen Hewitt27-May-10 21:40
Stephen Hewitt27-May-10 21:40 
GeneralRe: vector of doubles (division) Pin
Aescleal27-May-10 22:24
Aescleal27-May-10 22:24 
GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 5:24
b-rad31128-May-10 5:24 
GeneralRe: vector of doubles (division) Pin
Aescleal28-May-10 5:53
Aescleal28-May-10 5:53 
You're using a function with a hardcoded divisor in it, so the problem is how to get a second parameter into it.

If you want to keep using a function then you can expand your function to take a second parameter:

long double op_divide( long double numerator, long double denominator ) { return numerator/denominator; }


and use std::bind2nd to create a function object to pass to transform:

transform( vec.begin(), vec1.end(), vec2.begin(), std::bind2nd( op_divide, 5.0 ) );


[That's unchecked BTW, I'm not on a computer with a compiler on to check it - I'm pretty sure it will though.]

If you're doing that you could try using std::divides which does the same thing and saves writing the function.

Cheers,

Ash
GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 6:05
b-rad31128-May-10 6:05 
GeneralRe: vector of doubles (division) Pin
Aescleal28-May-10 7:20
Aescleal28-May-10 7:20 
GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 7:28
b-rad31128-May-10 7:28 
AnswerRe: vector of doubles (division) Pin
Stephen Hewitt27-May-10 14:09
Stephen Hewitt27-May-10 14:09 
GeneralRe: vector of doubles (division) Pin
b-rad31128-May-10 5:17
b-rad31128-May-10 5:17 
QuestionShow message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 6:48
manchukuo27-May-10 6:48 
AnswerRe: Show message the first time my app is started after windows has rebooted Pin
David Crow27-May-10 7:32
David Crow27-May-10 7:32 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 7:45
manchukuo27-May-10 7:45 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
David Crow27-May-10 8:22
David Crow27-May-10 8:22 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 9:11
manchukuo27-May-10 9:11 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
Iain Clarke, Warrior Programmer27-May-10 9:17
Iain Clarke, Warrior Programmer27-May-10 9:17 
GeneralRe: Show message the first time my app is started after windows has rebooted Pin
manchukuo27-May-10 9:20
manchukuo27-May-10 9:20 
AnswerRe: Show message the first time my app is started after windows has rebooted Pin
krmed27-May-10 8:59
krmed27-May-10 8:59 
AnswerRe: Show message the first time my app is started after windows has rebooted Pin
Bhaskar Sandbhor31-May-10 0:34
Bhaskar Sandbhor31-May-10 0:34 
QuestionHTTPS Pin
Fareed Rizkalla27-May-10 6:30
Fareed Rizkalla27-May-10 6:30 
AnswerRe: HTTPS PinPopular
Moak27-May-10 7:52
Moak27-May-10 7:52 
GeneralRe: HTTPS Pin
Stephen Hewitt27-May-10 19:42
Stephen Hewitt27-May-10 19:42 

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.