Skip to content

Instantly share code, notes, and snippets.

View madduci's full-sized avatar

Michele Adduci madduci

View GitHub Profile
@madduci
madduci / hello_world.cpp
Created December 15, 2014 07:19
Modern C++ - Hello World
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
@madduci
madduci / CMakeList.txt
Last active August 29, 2015 14:11
Modern C++ - Hello World CMake
project(FirstProject)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
@madduci
madduci / CMakeLists.txt
Last active August 29, 2015 14:11
Modern C++ - main CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
#-----------------------------
# Project Settings
#-----------------------------
SET(PROJECTNAME "ModernCpp")
PROJECT(${PROJECTNAME} CXX)
SET( ${PROJECT_NAME}_MAJOR_VERSION 0 )
SET( ${PROJECT_NAME}_MINOR_VERSION 1 )
@madduci
madduci / CMakeLists.txt
Last active August 29, 2015 14:11
Modern C++ - Modules/CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
add_subdirectory(Module1)
add_subdirectory(Module2)
add_subdirectory(Module3)
@madduci
madduci / CMakeLists.txt
Created December 16, 2014 10:33
Modern C++ - Applications/CMakeLists.txt
message( STATUS "-------------------------------------------------------------------------------" )
message( STATUS "Software configuration")
message( STATUS "-------------------------------------------------------------------------------" )
add_subdirectory(DemoApp1)
add_subdirectory(DemoApp2)
add_subdirectory(DemoApp3)
@madduci
madduci / CMakeLists.txt
Last active August 29, 2015 14:11
Modern C++ - Applications/DemoApp1/CMakeLists.txt
cmake_minimum_required(VERSION 2.8.11)
set(APPLICATION_NAME "${PROJECT_PREFIX_NAME}_demoapp_one")
project(${APPLICATION_NAME} CXX)
#Suppressing CMAKE 3.0 warnings
if(POLICY CMP0043)
cmake_policy(SET CMP0043 OLD)
endif()
@madduci
madduci / main.cpp
Created December 16, 2014 11:18
Modern C++ - Applications/DemoApp1/main.cpp
#include <iostream>
int main()
{
std::cout << "Hello world - DemoApp 1" << std::endl;
return 0;
}
@madduci
madduci / main.cpp
Last active August 29, 2015 14:12
Playing with variables
/*
Author: Michele Adduci <info@micheleadduci.net>
*/
#include <iostream>
#include <cmath>
int main()
{
std::cout << "The result of 3*3 is " << 3*3 << std::endl;
int var_a = 3*3;
@madduci
madduci / project_props.cmake
Created December 24, 2014 09:17
Enabling C++11 features
#Enables C++11 features
IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "-std=gnu++11")
ENDIF()
SET(CMAKE_COLOR_MAKEFILE ON)
@madduci
madduci / main.cpp
Last active August 29, 2015 14:12
Playing with vector
#include <iostream>
#include <vector>
int main()
{
std::vector<int> int_array; //array of integers, empty
std::vector<double> double_array_1; //array of doubles, empty
std::vector<double> double_array_2(10); //array of doubles, containing 10 elements initialized with 0.0
std::vector<double> double_array_3(10, 2.5f);//array of doubles, containing 10 elements initialized with 2.5
std::vector<double> double_array_4 {1.0, 2.0, 3.0, 4.0, 5.0}; //array initialized with some values