Cod sursa(job #3244160)

Utilizator gabrielvGabriel Vanca gabrielv Data 23 septembrie 2024 22:03:52
Problema A+B Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 2.57 kb
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>

using namespace std;


class HelloWorld
{
    public:
        HelloWorld()
        {
            // static bool           test_bool       = false;
            // static int            test_int        = 0;
            // static string         test_string     = "";
            // static vector<string> test_vector     = vector<string>();
            // static vector<int>    test_vector_int = vector<int>();
            // static HelloWorld*    test_pointer    = nullptr;
        }

        static void print()
        {
            static bool           test_bool       = false;
            static int            test_int        = 0;
            static string         test_string     = "";
            static vector<string> test_vector     = vector<string>();
            static vector<int>    test_vector_int = vector<int>();
            static HelloWorld*    test_pointer    = nullptr;

            cout << "test_bool: " << test_bool << endl;
            cout << "test_int: " << test_int << endl;
            cout << "test_string: " << test_string << endl;
            cout << "test_vector: ";
            for (auto& i : test_vector)
            {
                cout << i << " ";
            }
            cout << endl;
            cout << "test_vector_int: ";
            for (auto& i : test_vector_int)
            {
                cout << i << " ";
            }
            cout << endl;
            cout << "test_pointer: " << test_pointer << endl;


            test_bool = true;
            test_int++;
            test_string += "Hello World!";
            test_vector.push_back("Hello");
            test_vector.push_back("World!");
            test_vector_int.push_back(1);
            test_vector_int.push_back(2);
            test_pointer = new HelloWorld();
        }

        // static bool&           test_bool_;
        // static int&            test_int_;
        // static string&         test_string_;
        // static vector<string>& test_vector_;
        // static vector<int>&    test_vector_int_;
        // static HelloWorld* &   test_pointer_;
};


int main()
{
    cout << "Attempt 1: " << endl;
    HelloWorld* hello_world = new HelloWorld();
    hello_world->print();
    cout << endl;
    cout << "Attempt 2: " << endl;
    // hello_world = new HelloWorld();
    hello_world->print();
    cout << endl;
    cout << "Attempt 3: " << endl;
    // hello_world = new HelloWorld();
    hello_world->print();

    return 0;
}