Initial Commit

This commit is contained in:
Fries 2023-06-19 15:36:39 -07:00
commit cf27c686c2
11 changed files with 84 additions and 0 deletions

3
.clang-format Normal file
View file

@ -0,0 +1,3 @@
BasedOnStyle: WebKit
UseTab: Always
TabWidth: 4

4
.editorconfig Normal file
View file

@ -0,0 +1,4 @@
[*]
indent_style = tab
end_of_line = lf
insert_final_newline = true

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.cache
/build

4
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,4 @@
{
"editor.detectIndentation": false,
"editor.insertSpaces": false
}

2
meson.build Normal file
View file

@ -0,0 +1,2 @@
project('LearningProject', 'cpp')
subdir('src')

5
src/hello.cc Normal file
View file

@ -0,0 +1,5 @@
#include <iostream>
int main() {
std::cout << "hello" << std::endl;
}

38
src/inheritance.cc Normal file
View file

@ -0,0 +1,38 @@
#include <iostream>
#include <string>
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;
}
}

4
src/math.cc Normal file
View file

@ -0,0 +1,4 @@
#include "math.hh"
double Math::sqrt(double x) {
return x*x;
}

4
src/math.hh Normal file
View file

@ -0,0 +1,4 @@
class Math {
public:
double static sqrt(double x);
};

3
src/meson.build Normal file
View file

@ -0,0 +1,3 @@
executable('hello', 'hello.cc')
executable('sqrt', ['math.cc', 'sqrt.cc'])
executable('inheritance', 'inheritance.cc')

15
src/sqrt.cc Normal file
View file

@ -0,0 +1,15 @@
#include <iostream>
#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;
}