commit cf27c686c274182ca5217c989630c4f991c87b0c Author: Fries Date: Mon Jun 19 15:36:39 2023 -0700 Initial Commit diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..7e13c85 --- /dev/null +++ b/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: WebKit +UseTab: Always +TabWidth: 4 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c2e08b7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*] +indent_style = tab +end_of_line = lf +insert_final_newline = true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a03dcf1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.cache +/build diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..e74b756 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.detectIndentation": false, + "editor.insertSpaces": false +} diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..07fd168 --- /dev/null +++ b/meson.build @@ -0,0 +1,2 @@ +project('LearningProject', 'cpp') +subdir('src') diff --git a/src/hello.cc b/src/hello.cc new file mode 100644 index 0000000..43dc5fe --- /dev/null +++ b/src/hello.cc @@ -0,0 +1,5 @@ +#include + +int main() { + std::cout << "hello" << std::endl; +} diff --git a/src/inheritance.cc b/src/inheritance.cc new file mode 100644 index 0000000..2337b65 --- /dev/null +++ b/src/inheritance.cc @@ -0,0 +1,38 @@ +#include +#include + +class Crewmate { +public: + Crewmate(std::string name) + { + this->name = name; + } + std::string name; + static void PrintName(Crewmate crewmate) + { + std::cout << "Crewmates Name: " << crewmate.name << std::endl; + } +}; + +class Imposter : public Crewmate { +public: + Imposter(std::string name) + : Crewmate(name) + { + imposter = true; + } + bool imposter; +}; + +int main() +{ + Crewmate crewmate("Crewmate"); + Imposter imposter("Imposter"); + + crewmate.PrintName(imposter); + crewmate.PrintName(crewmate); + + if (imposter.imposter) { + std::cout << "Imposter is a sussy imposter and their name is " << imposter.name << std::endl; + } +} diff --git a/src/math.cc b/src/math.cc new file mode 100644 index 0000000..180d0e3 --- /dev/null +++ b/src/math.cc @@ -0,0 +1,4 @@ +#include "math.hh" +double Math::sqrt(double x) { + return x*x; +} diff --git a/src/math.hh b/src/math.hh new file mode 100644 index 0000000..337b738 --- /dev/null +++ b/src/math.hh @@ -0,0 +1,4 @@ +class Math { + public: + double static sqrt(double x); +}; diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000..fd2b1a9 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,3 @@ +executable('hello', 'hello.cc') +executable('sqrt', ['math.cc', 'sqrt.cc']) +executable('inheritance', 'inheritance.cc') diff --git a/src/sqrt.cc b/src/sqrt.cc new file mode 100644 index 0000000..959fc42 --- /dev/null +++ b/src/sqrt.cc @@ -0,0 +1,15 @@ +#include +#include "math.hh" + +double sqrt(double x); +void print_sqrt(double x); + +int main() { + print_sqrt(21.420); + print_sqrt(420); +} + +void print_sqrt(double x) { + std::cout << "the square root of " << x << " is " << Math::sqrt(x) << std::endl; +} +