Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am to prog some code on C++ which should calculate a fibonacci number in compiler time.
So it should look like this:
C++
int main()
{
  int v=???6???;
}


The six is the number of the fibonacci number 8.
And the question marks are some symbols which should be added to calculate the fibonacci number (in this case 6) in compiler time. So I need to see in object file already an answer (that 8 is written in variable v) (as the compiler alreay worked)
So we should see the instruction in object file, where 8 is put in v

What I have tried:

int main()
{
  int v=???6???;
}
I
I really have no ideas, could you please help?
Posted
Updated 29-Sep-19 23:14pm
v2

Hint: use a template whose template parameter is an int.

Stronger hint: search online for the same solution for a factorial and adapt it.
 
Share this answer
 
v2
 
Share this answer
 
Comments
Maciej Los 30-Sep-19 6:39am    
5ed!
Richard MacCutchan 30-Sep-19 6:46am    
Thanks, but I still do not really understand the question. :)
Maciej Los 30-Sep-19 8:04am    
Me too. I believe that Google is always good alternative.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900