Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- /*#define EXP 2.712312312
- #define CONFIG_FILE_NAME "config.ini"
- #define CONSOLE cout
- #define SQR(x) ((x)*(x))
- #define LOG_MODE
- */
- using namespace std;
- const double EXP = 2.712312;
- const char filename[]{ "config.ini" };
- void test_macros() {
- #ifdef LOG_MODE
- cout << "This is LOG MODE" << endl;
- #endif // LOG_MODE
- cout << "This is my prog" << endl;
- }
- const int sz = 10;
- int arr[sz];
- void genArr() {
- int k = 0;
- while (k < sz) {
- arr[k++] = k;
- }
- }
- void showArr() {
- int k = 0;
- while (k < sz) {
- cout << arr[k++] << " ";
- }
- cout << endl;
- }
- // Ссылка в качестве возвращаемого значения функции
- int& getMax() {
- int id = 0;
- for (int k = 1; k < sz; ++k)
- if (arr[k] > arr[id])
- id = k;
- return arr[id];
- }
- void test_reffromfun() {
- genArr();
- showArr();
- cout << getMax() << endl;
- int& x = getMax();
- cout << x << endl;
- x = 222;
- //getMax() = 134;
- showArr();
- }
- // Указатель на функцию
- void f1() {
- cout << "Fun1 " << endl;
- }
- void f2() {
- cout << "Fun2 " << endl;
- }
- int sum(int a, int b) {
- return a + b;
- }
- void main() {
- void (*pf)() = f1;
- pf();
- int (*pf2)(int, int) = sum;
- cout << pf2(21, 32) << endl;
- // автоматически сделать тип Y такой же как и у X;
- int x = 13;
- decltype(x) y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement