Skip to content

Commit 6663bb7

Browse files
added conent
1 parent 340b2ff commit 6663bb7

File tree

153 files changed

+7030
-24098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+7030
-24098
lines changed

.idea/editor.xml

+2-98
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Class_Overloading_by_Tanner_Davison/main.cpp

+47-11
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,89 @@ class House
88
House()=default;
99
House(int const sqftP, const Vector2D& vec)
1010
:sqft(sqftP), coord(vec){};
11-
virtual ~House()=default;
11+
~House()=default;
1212
void printHouse()const
1313
{
1414
std::cout<<"Sqft: "<< sqft << "\n" << "Coordinates: " << coord.x << " " << coord.y << std::endl;
1515
}
16-
16+
public:
1717
int sqft{};
1818
Vector2D coord;
1919
};
2020
class Family : public House
2121
{
2222
public:
23-
Family()=default;
23+
Family():members(0),head("unkown head"), wealth_status("unkown"){};
2424
Family(int const membersP, std::string headP): members(membersP), head(std::move(headP)){};
25-
Family(int const membersP, std::string headP, const House& house)
26-
:members(membersP), head(std::move(headP))
25+
Family( const House& houseP, int const membersP, std::string headP)
26+
:House(houseP), members(membersP), head(std::move(headP))
2727
{
28-
if(house.sqft < 1000)
28+
if(houseP.sqft < 1000)
2929
{
3030
wealth_status = "poor";
3131
}else
3232
{
3333
wealth_status = "wealthy";
3434
}
3535
};
36+
3637
void printFamilyInfo() const
3738
{
3839
std::cout << "Head Of House: " << head << "\nTotal Members: " << members << std::endl;
3940
House::printHouse();
4041
std::cout << "Status: " << wealth_status << std::endl;
4142
}
4243

43-
protected:
44+
public:
4445
int members{};
4546
std::string head{};
4647
std::string wealth_status{};
4748
};
4849

50+
class ExtendedFamily final : public Family{
51+
public:
52+
ExtendedFamily()
53+
:grandpa("unkown"), grandma("unknown"){};
54+
55+
ExtendedFamily(std::string grandpaP, std::string grandmaP)
56+
:grandpa(std::move(grandpaP)), grandma(std::move(grandmaP)){};
57+
58+
ExtendedFamily(const Family& familyP, std::string grandpaP, std::string grandmaP)
59+
:Family(familyP), grandpa(std::move(grandpaP)), grandma(std::move(grandmaP)){};
60+
61+
62+
void wholeFamily()const
63+
{
64+
std::cout << "Grandparents: " << grandpa << " " << grandma << "\nSon of grandparents: " << head << std::endl;
65+
}
66+
67+
public:
68+
std::string grandpa{};
69+
std::string grandma{};
70+
};
71+
void getFamilyInfo(string& headP, string& grandFatherP, string& grandmotherP, int& familyCount)
72+
{
73+
std::cout << "Enter Head of house and Total count of family members : ";
74+
std::getline(std::cin, headP);
75+
std::cin >>familyCount;
76+
std:: cout << "Enter the head of households parents starting with Dad and then Mom" << std::endl;
77+
std::cin.ignore();
78+
std::getline(std::cin, grandFatherP);
79+
std::getline(std::cin, grandmotherP);
80+
}
4981
int main() {
5082
std::string headOfHouse{};
83+
std::string grandFather{};
84+
std::string grandmother{};
5185
int familyCount{};
52-
std::cout << "Enter Head of house and Total count of family members : ";
53-
std::cin >> headOfHouse >> familyCount;
86+
getFamilyInfo(headOfHouse, grandFather, grandmother, familyCount);
5487
const Vector2D coordinates{1700, 1500};
5588
House const house{1001,coordinates};
56-
Family const family{familyCount, headOfHouse, house};
57-
89+
Family const family{house, familyCount, headOfHouse};
90+
ExtendedFamily const extendedFamily{family, grandFather, grandmother};
5891
family.printFamilyInfo();
92+
extendedFamily.wholeFamily();
93+
extendedFamily.printFamilyInfo();
94+
5995

6096
}

build/.DS_Store

-6 KB
Binary file not shown.

build/ALL_BUILD.vcxproj

+184
Large diffs are not rendered by default.

build/ALL_BUILD.vcxproj.filters

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<CustomBuild Include="C:\Users\Tanner\CLionProjects\Overloaded-Classes-by_Tanner_Davison\CMakeLists.txt" />
5+
</ItemGroup>
6+
<ItemGroup>
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)