C++ PROGRAM FOR FIBONACCI SERIES USING COPY CONSTRUCTER
Answer / Hari Krishna
Here is a simple example of a C++ program for the Fibonacci series using copy constructor. This code defines a class named Fibonacci, which has a private member 'num' to store the current number in the series.nn```cppn#include <iostream>nusing namespace std;nnclass Fibonacci {nprivate:n int num;npublic:n Fibonacci() { num = 0; }n Fibonacci(const Fibonacci &obj) { num = obj.num; }n void getFibonacci();n};nvoid Fibonacci::getFibonacci() {n if (num <= 1)n cout << num << " ";n else {n Fibonacci first( *this );n Fibonacci second;n first.getFibonacci();n second.num = first.num + this->num;n second.getFibonacci();n }n}nint main() {n Fibonacci fib1, fib2, fib3;n fib1.getFibonacci(); // Prints the first number in the series: 0n fib2 = fib1; // Copy constructor called here.n fib2.getFibonacci(); // Prints the second number in the series: 1n fib3 = fib2; // Copy constructor called here.n fib3.getFibonacci(); // Prints the third number in the series: 1 + 1 = 2.n return 0;n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
Please. Does someone know how to inicialize tapes in ATL? I need have 100 tapes to init inside the ATL, how is the process to complete this request?
why view is created in database
what happens if an error occurs in constructor or destructor.
What is the pressure in co2 cartridge in a DCP 5 kg extinguisher.
How can I get know that my pc contains dram or sram..?
What will be the sql query to list the employee names those are getting 3rd highest salary ?
what is active dirctory?
Apply Newton?s method to compute the approximate value of root 2. Start the iteration from x0=1, and obtain two iterations.
Implement the dictionary operations INSERT, DELETE, and SEARCH using singly linked, circular lists. What are the running times of your procedures?
What is meant by STL?
who are egoless programmers?
Can anyone tell me the exact formulae with explanation for the questions related to cube which is asked for CTS? I have seen varieties of formulae in different sites.I need the exact on... So pls help me out!!!
Civil Engineering (5086)
Mechanical Engineering (4453)
Electrical Engineering (16638)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)