Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std;
- double calcola_tolleranza() {return 0.2213;}
- class Manager {};
- auto big_data()
- {
- auto v = std::vector<int>(10000000);
- // elaborazione
- return v;
- }
- auto stima_coefficiente()
- {
- double coeff{};
- //logica che valorizza il coefficiente
- return coeff;
- }
- auto valuta_rischio()
- {
- static const auto coefficiente_iniziale{stima_coefficiente()}; //NON VORREMMO CAMBIASSE PIU
- //logica che valuta la posizione ...
- return "descrizione valutazione";
- }
- int test()
- {
- auto count{ 10 };
- auto pi{ 3.14159f };
- auto name{ std::string{"C++"} };
- auto v1 = std::vector<int> {1,4,6}; //DA PREFERIRE
- //std::vector<int> v1{1,4,6};
- /*std::unordered_map<std::string, std::vector<int>> mappa_utenti;
- int tentativi{ 5 };
- std::unique_ptr<Manager> gestore = std::make_unique<Manager>();*/
- auto mappa_utenti = std::unordered_map<std::string, std::vector<int>>{};
- auto tentativi = int{ 5 };
- auto gestore = std::make_unique<Manager>();
- auto tolleranza{calcola_tolleranza()};
- //for (int i = 0; i < v1.size(); ++i) { ... }
- return 0;
- }
- template <typename T>
- class Contenitore {
- public:
- using Iteratore = T*;
- Iteratore inizio();
- };
- //template <typename T>
- //typename Contenitore<T>::Iteratore Contenitore<T>::inizio() {
- // return nullptr;
- //}
- template <typename T>
- auto Contenitore<T>::inizio() -> Iteratore { return nullptr;}
- class Server {
- public:
- // Tipo annidato per dimostrare la risoluzione dello scope
- struct GestoreSessione {
- int id_sessione;
- };
- // Dichiarazioni dei metodi all'interno della classe
- void avvia();
- int ottieni_porta() const;
- std::vector<std::string> utenti_attivi();
- std::unique_ptr<GestoreSessione> crea_sessione(int id);
- };
- //void Server::avvia() { /* ... */ }
- //int Server::ottieni_porta() const { return 8080; }
- //std::vector<std::string> Server::utenti_attivi() { return {}; }
- //std::unique_ptr<Server::GestoreSessione> Server::crea_sessione(int id) { return nullptr; }
- auto Server::avvia() -> void { /* ... */ }
- auto Server::ottieni_porta() const -> int { return 8080; }
- auto Server::utenti_attivi() -> std::vector<std::string> { return {}; }
- auto Server::crea_sessione(int id) -> std::unique_ptr<GestoreSessione> { return nullptr; }
- auto avvia = []() -> void {/* ... */};
- // Trailing return type: 'Iteratore' è già nello scope di Contenitore
- auto main(int argc, char* argv[]) -> int
- {
- if (argc != 3)
- {
- std::println("Sono richiesti esattamente due nomi di file da confrontare");
- return 1;
- }
- std::println("E' stato lanciato il programma {}", argv[0]);
- std::string file1 = std::string(argv[1]);
- std::string file2{argv[2]};
- std::println("Sto confrontando {} con {} ...", argv[1], argv[2]);
- std::println("Sto confrontando {} con {} ...", file1, file2);
- }
Advertisement
Add Comment
Please, Sign In to add comment