Created
December 2, 2014 01:11
-
-
Save MayukhSobo/3f6cd044996b321b95c5 to your computer and use it in GitHub Desktop.
This projects shows that how OOPs in C++11 & its extensive form can be used to demonstrate a simple concept of Fibonacii Series
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 2.8.4) | |
project(test) | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
set(SOURCE_FILES main.cpp test.h test.cpp) | |
add_executable(test ${SOURCE_FILES}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
/*For CLion #include <string> is not needed */ | |
//#include <string> | |
#include "test.h" | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
int value = stoi(argv[1], nullptr, 10); | |
static Fibonacii Fibo(value); | |
Fibo.create_series(); | |
Fibo.get_data(); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "test.h" | |
#include <iostream> | |
using namespace std; | |
// This creates a Fibonacii series | |
void Fibonacii::create_series(void){ | |
data.push_back(0); | |
data.push_back(1); | |
for (int i = 2; i < size; ++i) | |
{ | |
/* code */ | |
data.push_back(data[i - 2] + data[i - 1]); | |
} | |
} | |
// This is a constructor | |
Fibonacii::Fibonacii(int s){ | |
size = s; | |
} | |
// This method is used to print the series | |
void Fibonacii::get_data(void){ | |
for (long i: data) | |
cout << i << endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef _test_h_ | |
#define _test_h_ | |
#include <vector> | |
class Fibonacii{ | |
private: | |
int size; | |
std::vector<long> data; | |
public: | |
Fibonacii(int); | |
void create_series(void); | |
void get_data(void); | |
}; | |
#endif // _test_h_ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment