diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..c2098a2 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "linux-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "/usr/bin/gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "linux-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0def71e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": false, + "cwd": "/home/rattatwinko/Dokumente/CPP/CPP", + "program": "/home/rattatwinko/Dokumente/CPP/CPP/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 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bb879da --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "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:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat", + "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 diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..05054c5 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: g++ build active file", + "command": "/usr/bin/g++", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}/${fileBasenameNoExtension}" + ], + "options": { + "cwd": "${fileDirname}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/OOP/access_specifier/ex2 b/OOP/access_specifier/ex2 new file mode 100755 index 0000000..3b7d09a Binary files /dev/null and b/OOP/access_specifier/ex2 differ diff --git a/OOP/access_specifier/ex2.cpp b/OOP/access_specifier/ex2.cpp new file mode 100644 index 0000000..8d7d598 --- /dev/null +++ b/OOP/access_specifier/ex2.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; + +/* + Here we have the protected specifier which lets a class inherit a variable (in this example it is salary!) +*/ + +class Employee { + protected: + int salary; +}; + +class Programmer: public Employee { + public: + int bonus; + void setSalary(int s) { + salary = s; + } + int getSalary() { + return salary; + } +}; + +int main() { + Programmer classobj; + classobj.setSalary(1000); + classobj.bonus = 200; + + cout << "Salary for Programmer Class: " << classobj.getSalary() << "\n"; + cout << "Bonus for Programmer Class: " << classobj.bonus << "\n"; + + return 0; +} \ No newline at end of file diff --git a/OOP/constructor/car_outside b/OOP/constructor/car_outside new file mode 100755 index 0000000..0be6692 Binary files /dev/null and b/OOP/constructor/car_outside differ diff --git a/OOP/encapsulation/main b/OOP/encapsulation/main new file mode 100755 index 0000000..edbcd9e Binary files /dev/null and b/OOP/encapsulation/main differ diff --git a/OOP/encapsulation/main.cpp b/OOP/encapsulation/main.cpp new file mode 100644 index 0000000..a595022 --- /dev/null +++ b/OOP/encapsulation/main.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +class Employee { + private: + int salary; + public: + // Setter + void setSalary(int s) { + salary = s; + } + int getSalary() { + return salary; + } + +}; + +int main() { + Employee myObj; + myObj.setSalary(123000); + cout << myObj.getSalary(); + return 0; +} \ No newline at end of file diff --git a/OOP/inheritance/Vehicle b/OOP/inheritance/Vehicle new file mode 100755 index 0000000..f8f4402 Binary files /dev/null and b/OOP/inheritance/Vehicle differ diff --git a/OOP/inheritance/Vehicle.cpp b/OOP/inheritance/Vehicle.cpp new file mode 100644 index 0000000..b3dd8c4 --- /dev/null +++ b/OOP/inheritance/Vehicle.cpp @@ -0,0 +1,23 @@ +#include + +using namespace std; + +class Vehicle { + public: + string brand = "Ford"; + void honk() { + cout << "Honk Honk!"; + } +}; + +class Car: public Vehicle { + public: + string model = "Mustang"; +}; + +int main() { + Car myCar; + myCar.honk(); + cout << myCar.brand + " " + myCar.model << "\n"; + return 0; +} \ No newline at end of file diff --git a/OOP/inheritance/multilevel b/OOP/inheritance/multilevel new file mode 100755 index 0000000..ea1221e Binary files /dev/null and b/OOP/inheritance/multilevel differ diff --git a/OOP/inheritance/multilevel.cpp b/OOP/inheritance/multilevel.cpp new file mode 100644 index 0000000..ef58911 --- /dev/null +++ b/OOP/inheritance/multilevel.cpp @@ -0,0 +1,24 @@ +#include + +using namespace std; + +class Parent { + public: + void function() { + cout << "Parent Class!"; + } +}; + +class MyChild: public Parent { + // Child Function here +}; + +class MyGrandChild: public MyChild { + // Grandchild Function here +}; + +int main() { + MyGrandChild classobj; + classobj.function(); + return 0; +} \ No newline at end of file diff --git a/OOP/inheritance/multiple_inheritance b/OOP/inheritance/multiple_inheritance new file mode 100755 index 0000000..a34ef8f Binary files /dev/null and b/OOP/inheritance/multiple_inheritance differ diff --git a/OOP/inheritance/multiple_inheritance.cpp b/OOP/inheritance/multiple_inheritance.cpp new file mode 100644 index 0000000..184c033 --- /dev/null +++ b/OOP/inheritance/multiple_inheritance.cpp @@ -0,0 +1,27 @@ +#include + +using namespace std; + +class myClass { + public: + void myClass_one() { + cout << "Hello World!"; + } +}; + +class MyOtherClass { + public: + void MyOtherClass_Function() { + cout << "Hello, I am a other Function!"; + } +}; + +class myChildClass: public myClass, public MyOtherClass { +}; + +int main() { + myChildClass classobj; + classobj.myClass_one(); + classobj.MyOtherClass_Function(); + return 0; +} \ No newline at end of file