Initial commit

This commit is contained in:
2022-07-17 20:42:42 +02:00
commit 4f3fce48e1
10 changed files with 2887 additions and 0 deletions

7
cpp/01-hello.cpp Normal file
View File

@ -0,0 +1,7 @@
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!";
return 0;
}

9
cpp/02-days.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <iostream>
#include <string>
int main() {
const std::string days[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
std::cout << days[4];
std::cout << '\n';
return 0;
}

9
cpp/03-refs.cpp Normal file
View File

@ -0,0 +1,9 @@
#include <iostream>
#include <string>
int main() {
std::string str = "Post box:";
std::cout << str << '\n';
std::cout << &str << '\n';
}

28
cpp/04-pointers.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <iostream>
#include <string>
int main() {
std::string tapa = "calamares";
std::string* pointer = &tapa;
std::cout << "tapa " << tapa << "\n";
std::cout << "&tapa " << &tapa << "\n";
std::cout << "pointer " << pointer << "\n";
std::cout << "*pointer " << *pointer << "\n\n";
tapa = "albondigas";
std::cout << "tapa " << tapa << "\n";
std::cout << "&tapa " << &tapa << "\n";
std::cout << "pointer " << pointer << "\n";
std::cout << "*pointer " << *pointer << "\n\n";
*pointer = "croquetas de jamón";
std::cout << "tapa " << tapa << "\n";
std::cout << "&tapa " << &tapa << "\n";
std::cout << "pointer " << pointer << "\n";
std::cout << "*pointer " << *pointer << "\n";
return 0;
}