0

How to add fiction to an array?

How to add function to an array???

7th Dec 2019, 5:18 PM
Diptansu das
Diptansu das - avatar
4 Answers
+ 3
( 🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ! He might have learnt it elsewhere ^^) What do you mean by that ? Passing an array as parameter to a function ? Returning an array ? An array of functions ? All that at once ? Obi wan Kenobi ?
7th Dec 2019, 7:25 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
simple example: #include <iostream> using namespace std; int funct1(int x, int y){ return x * y; } int funct2(int x, int y){ return x * y; } int funct3(int x, int y){ return x * y; } int main() { int myarr[] = {funct1(2, 4), funct2(2, 5), funct3(2, 6)}; for(unsigned int i = 0; i < 3; i++) cout << myarr[i] << endl; return 0; } ...yet to work out how to do the same if the function are type void.
7th Dec 2019, 8:50 PM
rodwynnejones
rodwynnejones - avatar
+ 1
You didn't start to learn C language and you are going in detail. How? First go and learn about function and array. Don't ask such type of question before knowing about that.
7th Dec 2019, 7:23 PM
A͢J
A͢J - avatar
0
What do you want to store if they return nothing ?
7th Dec 2019, 9:50 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar