diff --git a/CPlusPlus/CPlusPlus.sln b/CPlusPlus/CPlusPlus.sln index 1cee459..aae379d 100644 --- a/CPlusPlus/CPlusPlus.sln +++ b/CPlusPlus/CPlusPlus.sln @@ -1,10 +1,14 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.13.35828.75 d17.13 +VisualStudioVersion = 17.13.35828.75 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\HelloWorld.vcxproj", "{92B0EF46-7137-453A-A7A9-E02D6CE07D8D}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "forward_declaration", "forward_declaration\forward_declaration.vcxproj", "{2FC9F683-346A-4A58-9294-DB811A2EEC20}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Classes", "Classes\Classes.vcxproj", "{467AD272-2BB3-41B7-9B74-7D193D7D2AE9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -27,6 +31,30 @@ Global {92B0EF46-7137-453A-A7A9-E02D6CE07D8D}.Release|x64.Build.0 = Release|x64 {92B0EF46-7137-453A-A7A9-E02D6CE07D8D}.Release|x86.ActiveCfg = Release|Win32 {92B0EF46-7137-453A-A7A9-E02D6CE07D8D}.Release|x86.Build.0 = Release|Win32 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Debug|ARM64.Build.0 = Debug|ARM64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Debug|x64.ActiveCfg = Debug|x64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Debug|x64.Build.0 = Debug|x64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Debug|x86.ActiveCfg = Debug|Win32 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Debug|x86.Build.0 = Debug|Win32 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Release|ARM64.ActiveCfg = Release|ARM64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Release|ARM64.Build.0 = Release|ARM64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Release|x64.ActiveCfg = Release|x64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Release|x64.Build.0 = Release|x64 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Release|x86.ActiveCfg = Release|Win32 + {2FC9F683-346A-4A58-9294-DB811A2EEC20}.Release|x86.Build.0 = Release|Win32 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Debug|ARM64.Build.0 = Debug|ARM64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Debug|x64.ActiveCfg = Debug|x64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Debug|x64.Build.0 = Debug|x64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Debug|x86.ActiveCfg = Debug|Win32 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Debug|x86.Build.0 = Debug|Win32 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Release|ARM64.ActiveCfg = Release|ARM64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Release|ARM64.Build.0 = Release|ARM64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Release|x64.ActiveCfg = Release|x64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Release|x64.Build.0 = Release|x64 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Release|x86.ActiveCfg = Release|Win32 + {467AD272-2BB3-41B7-9B74-7D193D7D2AE9}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CPlusPlus/Classes/Classes.vcxproj b/CPlusPlus/Classes/Classes.vcxproj new file mode 100644 index 0000000..22f8981 --- /dev/null +++ b/CPlusPlus/Classes/Classes.vcxproj @@ -0,0 +1,200 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + 17.0 + Win32Proj + {467ad272-2bb3-41b7-9b74-7d193d7d2ae9} + Classes + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CPlusPlus/Classes/Classes.vcxproj.filters b/CPlusPlus/Classes/Classes.vcxproj.filters new file mode 100644 index 0000000..83cfedb --- /dev/null +++ b/CPlusPlus/Classes/Classes.vcxproj.filters @@ -0,0 +1,48 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/CPlusPlus/Classes/Entity.cpp b/CPlusPlus/Classes/Entity.cpp new file mode 100644 index 0000000..a379a02 --- /dev/null +++ b/CPlusPlus/Classes/Entity.cpp @@ -0,0 +1,16 @@ +#include "Entity.h" + +Entity::Entity() +{ + +} + +Entity::Entity(std::string name) : name(name) +{ + //this->name = name; +} + +std::string Entity::ToString() +{ + return name; +} \ No newline at end of file diff --git a/CPlusPlus/Classes/Entity.h b/CPlusPlus/Classes/Entity.h new file mode 100644 index 0000000..891d032 --- /dev/null +++ b/CPlusPlus/Classes/Entity.h @@ -0,0 +1,14 @@ +#pragma once +#include + +class Entity +{ +public: + Entity(); + Entity(std::string name); + + virtual std::string ToString(); + + std::string name = ""; + +}; // IMPORTANT: semicolon at the end \ No newline at end of file diff --git a/CPlusPlus/Classes/ICompareable.h b/CPlusPlus/Classes/ICompareable.h new file mode 100644 index 0000000..7c86328 --- /dev/null +++ b/CPlusPlus/Classes/ICompareable.h @@ -0,0 +1,7 @@ +#pragma once + +class ICompareable +{ +public: + virtual int Compare(ICompareable* other) = 0; +}; \ No newline at end of file diff --git a/CPlusPlus/Classes/Monster.cpp b/CPlusPlus/Classes/Monster.cpp new file mode 100644 index 0000000..b519743 --- /dev/null +++ b/CPlusPlus/Classes/Monster.cpp @@ -0,0 +1,18 @@ +#include "Monster.h" + +Monster::Monster(int strength) : Entity("My Monster"), _strength(strength) +{ + this->name = "My Monster"; +} + +std::string Monster::ToString() +{ + return name + " " + "(" + std::to_string(_strength) + ")"; + // TODO: show format +} + +int Monster::Compare(ICompareable* other) +{ + // TODO: implement later + return 0; +} diff --git a/CPlusPlus/Classes/Monster.h b/CPlusPlus/Classes/Monster.h new file mode 100644 index 0000000..d203d51 --- /dev/null +++ b/CPlusPlus/Classes/Monster.h @@ -0,0 +1,16 @@ +#pragma once +#include "Entity.h" +#include "ICompareable.h" + +class Monster : public Entity, public ICompareable +{ +public: + Monster(int strength); + + virtual void Move() = 0; // abstract (pure virtual method) + std::string ToString() override; + int Compare(ICompareable* other) override; + +protected: + int _strength = 0; +}; \ No newline at end of file diff --git a/CPlusPlus/Classes/Ork.cpp b/CPlusPlus/Classes/Ork.cpp new file mode 100644 index 0000000..8f051da --- /dev/null +++ b/CPlusPlus/Classes/Ork.cpp @@ -0,0 +1,11 @@ +#include "Ork.h" + +Ork::Ork() : Monster(10) +{ + //this->_strength = 10; + this->name = "My Ork"; +} + +void Ork::Move() +{ +} diff --git a/CPlusPlus/Classes/Ork.h b/CPlusPlus/Classes/Ork.h new file mode 100644 index 0000000..e837f32 --- /dev/null +++ b/CPlusPlus/Classes/Ork.h @@ -0,0 +1,11 @@ +#pragma once +#include "Monster.h" + +class Ork : public Monster +{ +public: + Ork(); + + void Move() override; +}; + diff --git a/CPlusPlus/Classes/Vector3.h b/CPlusPlus/Classes/Vector3.h new file mode 100644 index 0000000..e0bbcb5 --- /dev/null +++ b/CPlusPlus/Classes/Vector3.h @@ -0,0 +1,11 @@ +#pragma once + +struct Vector3 +{ + float x; + float y; + float z; + + Vector3() : x(0.0f), y(0.0f), z(0.0f) {} + Vector3(float x, float y, float z) : x(x), y(y), z(z) {} +}; \ No newline at end of file diff --git a/CPlusPlus/Classes/main.cpp b/CPlusPlus/Classes/main.cpp new file mode 100644 index 0000000..abe05a8 --- /dev/null +++ b/CPlusPlus/Classes/main.cpp @@ -0,0 +1,27 @@ +#include + +#include "Entity.h" +#include "Ork.h" +#include "Vector3.h" + +using namespace std; + +int main() +{ + Entity entity; // this is an entity instance + entity.name = "My Entity"; + + //Monster monster; // can't be instantiated, because Monster is abstract + + Ork ork; + ork.name = "My Ork"; + ork.Move(); + + cout << entity.ToString() << endl; + cout << ork.ToString() << endl; + + Vector3 position(1.0f, 3.0f, -5.0f); + position.y = 0.0f; + + return 0; +} \ No newline at end of file diff --git a/CPlusPlus/forward_declaration/forward_declaration.vcxproj b/CPlusPlus/forward_declaration/forward_declaration.vcxproj new file mode 100644 index 0000000..fd4fbe1 --- /dev/null +++ b/CPlusPlus/forward_declaration/forward_declaration.vcxproj @@ -0,0 +1,194 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + 17.0 + Win32Proj + {2fc9f683-346a-4a58-9294-db811a2eec20} + forwarddeclaration + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/CPlusPlus/forward_declaration/forward_declaration.vcxproj.filters b/CPlusPlus/forward_declaration/forward_declaration.vcxproj.filters new file mode 100644 index 0000000..54bcd79 --- /dev/null +++ b/CPlusPlus/forward_declaration/forward_declaration.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/CPlusPlus/forward_declaration/functions.cpp b/CPlusPlus/forward_declaration/functions.cpp new file mode 100644 index 0000000..e9df689 --- /dev/null +++ b/CPlusPlus/forward_declaration/functions.cpp @@ -0,0 +1,3 @@ +#include "functions.h" + +void functionE() {} // definition \ No newline at end of file diff --git a/CPlusPlus/forward_declaration/functions.h b/CPlusPlus/forward_declaration/functions.h new file mode 100644 index 0000000..b27875c --- /dev/null +++ b/CPlusPlus/forward_declaration/functions.h @@ -0,0 +1,9 @@ +#pragma once + +#ifndef _FUNCTIONS_H_ +#define _FUNCTIONS_H_ + +void functionE(); // declaration +//void functionF() {} // defined & declared, linker error when included multiple times + +#endif // _FUNCTIONS_H_ diff --git a/CPlusPlus/forward_declaration/main.cpp b/CPlusPlus/forward_declaration/main.cpp new file mode 100644 index 0000000..fd732f5 --- /dev/null +++ b/CPlusPlus/forward_declaration/main.cpp @@ -0,0 +1,21 @@ +#include "functions.h" + +void functionB() {} // declared & defined +void functionC(); // declare +void functionD(); // foward declare + +int main() +{ + //functionA(); // compiler error, because function is declared & defined after this call + functionB(); // no error + //functionC(); // linker error, because function is declared, but not defined + functionD(); + functionE(); + //functionF(); // linker error, because header file was included multiple times with a definition + + return 0; +} + +void functionA() {} // declare & defined + +void functionD() {} // definition \ No newline at end of file