Skip to content
Snippets Groups Projects
Commit dccd2413 authored by Adrian Josef Waldvogel's avatar Adrian Josef Waldvogel
Browse files

Übungsprogramm 21 abgeschlossen

parent 1766c0b8
No related branches found
No related tags found
No related merge requests found
{
"configurations": [
{
"name": "windows-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "C:/msys64/ucrt64/bin/gcc.exe",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "windows-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
\ No newline at end of file
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": true,
"cwd": "c:/Users/adria/Documents/Schule/OST/Repositories/praktika-grulait/Pruefungsvorbereitung/Programme/Uebungsprogramm21",
"program": "c:/Users/adria/Documents/Schule/OST/Repositories/praktika-grulait/Pruefungsvorbereitung/Programme/Uebungsprogramm21/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
\ No newline at end of file
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
\ No newline at end of file
File added
File added
File added
File added
# include <iostream>
/*
inheritance = A class can recieve attributes and methods from another class
Children classes inhert from a Parent Class
Helps to reuse similiar code found within multiple classes
note that the definition and implementation of classes usually get separated in different files
https://www.youtube.com/watch?v=-TkoO8Z07hI -> 05:48:59 - 06:00:00
*/
class Animal {
public:
bool alive = true;
void eat() {
std::cout << "NOM NOM NOM\n";
}
};
class Dog : public Animal {
public:
void bark() {
std::cout << "The dog goes woof!\n";
}
};
class Cat : public Animal {
public:
void meow() {
std::cout << "The cat goes meow!\n";
}
};
class Shape {
public:
double area;
double volume;
};
class Cube : public Shape{
public:
Cube(double x) {
side = x;
area = side * side * 6;
volume = side * side * side;
}
double side;
};
class Sphere : public Shape{
public:
Sphere(double y) {
radius = y;
area = 4 * 3.14159 * (radius * radius);
volume = (4/3.0) * 3.14159 * radius * radius * radius;
}
double radius;
};
int main() {
Cube cube{10};
Sphere sphere{5};
std::cout << "Area: " << cube.area << " cm^2\n";
std::cout << "Volume: " << cube.volume << " cm^3\n";
std::cout << "Area: " << sphere.area << " cm^2\n";
std::cout << "Volume: " << sphere.volume << " cm^3\n";
Dog dog;
Cat cat;
std::cout << dog.alive << "\n";
dog.eat();
dog.bark();
std::cout << cat.alive << "\n";
cat.eat();
cat.meow();
return 0;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment