From 49132eb2125d7abe6d24279bb5b6e5c79b88dffd Mon Sep 17 00:00:00 2001 From: rPatrickWarner Date: Mon, 26 Feb 2024 18:57:43 -0800 Subject: init --- Homework8/Homework8.sln | 41 ++++++ Homework8/Homework8/Homework8.vcxproj | 138 +++++++++++++++++++++ Homework8/Homework8/Homework8.vcxproj.filters | 22 ++++ Homework8/Homework8/main.cpp | 24 ++++ Homework8/MyStructures/Contact.hpp | 108 ++++++++++++++++ Homework8/MyStructures/ContactList.hpp | 119 ++++++++++++++++++ Homework8/MyStructures/MyStructures.vcxproj | 136 ++++++++++++++++++++ .../MyStructures/MyStructures.vcxproj.filters | 7 ++ 8 files changed, 595 insertions(+) create mode 100644 Homework8/Homework8.sln create mode 100644 Homework8/Homework8/Homework8.vcxproj create mode 100644 Homework8/Homework8/Homework8.vcxproj.filters create mode 100644 Homework8/Homework8/main.cpp create mode 100644 Homework8/MyStructures/Contact.hpp create mode 100644 Homework8/MyStructures/ContactList.hpp create mode 100644 Homework8/MyStructures/MyStructures.vcxproj create mode 100644 Homework8/MyStructures/MyStructures.vcxproj.filters (limited to 'Homework8') diff --git a/Homework8/Homework8.sln b/Homework8/Homework8.sln new file mode 100644 index 0000000..a8ed990 --- /dev/null +++ b/Homework8/Homework8.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34330.188 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Homework8", "Homework8\Homework8.vcxproj", "{F8F29D9D-81A6-4530-AFE2-E71934846A6D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MyStructures", "MyStructures\MyStructures.vcxproj", "{BF896E58-AEC3-431B-9FE4-6F7061977AA2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Debug|x64.ActiveCfg = Debug|x64 + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Debug|x64.Build.0 = Debug|x64 + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Debug|x86.ActiveCfg = Debug|Win32 + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Debug|x86.Build.0 = Debug|Win32 + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Release|x64.ActiveCfg = Release|x64 + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Release|x64.Build.0 = Release|x64 + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Release|x86.ActiveCfg = Release|Win32 + {F8F29D9D-81A6-4530-AFE2-E71934846A6D}.Release|x86.Build.0 = Release|Win32 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Debug|x64.ActiveCfg = Debug|x64 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Debug|x64.Build.0 = Debug|x64 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Debug|x86.ActiveCfg = Debug|Win32 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Debug|x86.Build.0 = Debug|Win32 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Release|x64.ActiveCfg = Release|x64 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Release|x64.Build.0 = Release|x64 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Release|x86.ActiveCfg = Release|Win32 + {BF896E58-AEC3-431B-9FE4-6F7061977AA2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {72DD9867-97FA-44EA-B829-06173F09D886} + EndGlobalSection +EndGlobal diff --git a/Homework8/Homework8/Homework8.vcxproj b/Homework8/Homework8/Homework8.vcxproj new file mode 100644 index 0000000..0ad5b45 --- /dev/null +++ b/Homework8/Homework8/Homework8.vcxproj @@ -0,0 +1,138 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {f8f29d9d-81a6-4530-afe2-e71934846a6d} + Homework8 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + C:\Users\rpwar\source\repos\OIT-WI-2024\Homework8\homework-8-reecepwarner\Homework8\MyStructures;$(IncludePath) + + + + 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 + + + + + + + + + \ No newline at end of file diff --git a/Homework8/Homework8/Homework8.vcxproj.filters b/Homework8/Homework8/Homework8.vcxproj.filters new file mode 100644 index 0000000..ce0c35c --- /dev/null +++ b/Homework8/Homework8/Homework8.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {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 + + + \ No newline at end of file diff --git a/Homework8/Homework8/main.cpp b/Homework8/Homework8/main.cpp new file mode 100644 index 0000000..37aad74 --- /dev/null +++ b/Homework8/Homework8/main.cpp @@ -0,0 +1,24 @@ +//Name:Reece Waner + +#include "Contact.hpp" + +using namespace MyStructures; //bringing scope into the main + + +int main() +{ + + Contact newContact; + + + + + + + + + + + + return 0; +} \ No newline at end of file diff --git a/Homework8/MyStructures/Contact.hpp b/Homework8/MyStructures/Contact.hpp new file mode 100644 index 0000000..f7fda6c --- /dev/null +++ b/Homework8/MyStructures/Contact.hpp @@ -0,0 +1,108 @@ +#ifndef CONTACT_HPP +#define CONTACT_HPP + +namespace MyStructures //variables declared here act as a global variable +{ + template + class Contact + { + public: + Contact() = default; + Contact(const char* name, const short age); + + ~Contact() = default; + + Contact(const Contact& copy); //copy constructor + Contact& operator=(const Contact& rhs); //copy assignment + + Contact(Contact&& move); //move constructor + Contact& operator=(Contact&& rhs); //move assignment + + + short GetAge(); + const char* GetName(); + + void SetAge(short age); + void SetName(const char* name); + + void Print(); + + T GetCustomValue(T& newValue); + + private: + const char* name_{}; + short age_{ 0 }; + T custom_value_{}; //one type is declared, it will be custom + + + }; + + + template + Contact::Contact(const char* name, const short age) + { + } + + template + Contact::Contact(const Contact& copy) + { + } + + template + Contact& Contact::operator=(const Contact& rhs) + { + // TODO: insert return statement here + } + + template + Contact::Contact(Contact&& move) + { + } + + template + Contact& Contact::operator=(Contact&& rhs) + { + // TODO: insert return statement here + } + + + + template + short Contact::GetAge() + { + return 0; + } + + template + const char* Contact::GetName() + { + return nullptr; + } + + template + void Contact::SetAge(short age) + { + } + + template + void Contact::SetName(const char* name) + { + } + + template + inline void Contact::Print() + { + } + + template + T Contact::GetCustomValue(T& newValue) + { + custom_value_ = newValue + return T(); + } + +} + + + +#endif \ No newline at end of file diff --git a/Homework8/MyStructures/ContactList.hpp b/Homework8/MyStructures/ContactList.hpp new file mode 100644 index 0000000..dd0f4ee --- /dev/null +++ b/Homework8/MyStructures/ContactList.hpp @@ -0,0 +1,119 @@ +#ifndef CONTACT_LIST_HPP +#define CONTACT_LIST_HPP + +namespace MyStructures +{ + template + class ContactList + { + public: + ContactList() = default; + ContactList(size_t size); //Creates contact list of this size + ContactList(const C* contacts, const size_t& length); //Makes a copy of another contact list + ~ContactList(); + + ContactList(const ContactList& copy); //deep copy constructor + ContactList& operator=(const ContactList& rhs); //deep copy assignment + + ContactList(ContactList&& move); //reference(move) constructor + ContactList& operator=(ContactList&& rhs); //reference(move) assignment + + private: + C* contacts_{ nullptr }; + size_t length_{ 0 }; //entire length of array + size_t size_{ 0 }; //number of actual elements + + C* AllocateContactList(const size_t& length); + }; + template + ContactList::ContactList(size_t size) + { + contacts_ = AllocateContactList(size); + } + template + ContactList::ContactList(const C* contacts, const size_t& length) + { + contacts_ AllocateContactList(length); + for (auto i = 0u; i < length; ++i) + { + contacts_[i] = contacts[i]; + } + } + template + ContactList::~ContactList() + { + delete[] contacts_; + contacts_ = nullptr; + } + template + ContactList::ContactList(const ContactList& copy) + { + length_ = copy.length_; + size_ = copy.size_; + contacts_ = AllocateContactList(copy.length_); + + contacts_ AllocateContactList(length); + for (auto i = 0u; i < length_; ++i) + { + contacts_[i] = copy[i]; + } + + } + template + ContactList&ContactList::operator=(const ContactList& rhs) + { + if (this != &rhs) //asking if they're the same object + { + delete[] contacts_; + contacts_ = nullptr; + + contacts_ = AllocateContactList(rhs.length_); + size_ = rhs.size_; + contacts_ AllocateContactList(length); + + for (auto i = 0u; i < length_; ++i) + { + contacts_[i] = rhs[i]; + } + } + return *this; + } + template + ContactList::ContactList(ContactList&& move) + { + *this = std::move(move); //move shifts addresses + } + template + ContactList& ContactList::operator=(ContactList&& rhs) + { + if(this != &rhs) + { + delete[] contacts_; + contacts = nullptr; + + contacts_ = rhs.contacts_; + + length_ = rhs.length_; + size_ = rhs.size_; + + rhs.contacts_ = nullptr; //Invalidate the other object + } + template + C* ContactList::AllocateContactList(const size_t& length) + { + C* storage = nullptr + length_ - length; + + storage = newC[length]{}; + + return storage; + } +}; +} + + + + + + +#endif \ No newline at end of file diff --git a/Homework8/MyStructures/MyStructures.vcxproj b/Homework8/MyStructures/MyStructures.vcxproj new file mode 100644 index 0000000..92eff89 --- /dev/null +++ b/Homework8/MyStructures/MyStructures.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 17.0 + Win32Proj + {bf896e58-aec3-431b-9fe4-6f7061977aa2} + MyStructures + 10.0 + + + + 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 + + + + + + + + + + \ No newline at end of file diff --git a/Homework8/MyStructures/MyStructures.vcxproj.filters b/Homework8/MyStructures/MyStructures.vcxproj.filters new file mode 100644 index 0000000..deeda6d --- /dev/null +++ b/Homework8/MyStructures/MyStructures.vcxproj.filters @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file -- cgit v1.2.3