Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4cc8ad1

Browse files
Pointer to an object in the heap
1 parent 0c91da1 commit 4cc8ad1

File tree

8 files changed

+370
-0
lines changed

8 files changed

+370
-0
lines changed

‎.DS_Store

6 KB
Binary file not shown.
6 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 56;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
DE44A2002AF6E31C0014DA78 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE44A1FF2AF6E31C0014DA78 /* main.cpp */; };
11+
/* End PBXBuildFile section */
12+
13+
/* Begin PBXCopyFilesBuildPhase section */
14+
DE44A1FA2AF6E31C0014DA78 /* CopyFiles */ = {
15+
isa = PBXCopyFilesBuildPhase;
16+
buildActionMask = 2147483647;
17+
dstPath = /usr/share/man/man1/;
18+
dstSubfolderSpec = 0;
19+
files = (
20+
);
21+
runOnlyForDeploymentPostprocessing = 1;
22+
};
23+
/* End PBXCopyFilesBuildPhase section */
24+
25+
/* Begin PBXFileReference section */
26+
DE44A1FC2AF6E31C0014DA78 /* Pointer_to_an_object_in_heap */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Pointer_to_an_object_in_heap; sourceTree = BUILT_PRODUCTS_DIR; };
27+
DE44A1FF2AF6E31C0014DA78 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
28+
/* End PBXFileReference section */
29+
30+
/* Begin PBXFrameworksBuildPhase section */
31+
DE44A1F92AF6E31C0014DA78 /* Frameworks */ = {
32+
isa = PBXFrameworksBuildPhase;
33+
buildActionMask = 2147483647;
34+
files = (
35+
);
36+
runOnlyForDeploymentPostprocessing = 0;
37+
};
38+
/* End PBXFrameworksBuildPhase section */
39+
40+
/* Begin PBXGroup section */
41+
DE44A1F32AF6E31C0014DA78 = {
42+
isa = PBXGroup;
43+
children = (
44+
DE44A1FE2AF6E31C0014DA78 /* Pointer_to_an_object_in_heap */,
45+
DE44A1FD2AF6E31C0014DA78 /* Products */,
46+
);
47+
sourceTree = "<group>";
48+
};
49+
DE44A1FD2AF6E31C0014DA78 /* Products */ = {
50+
isa = PBXGroup;
51+
children = (
52+
DE44A1FC2AF6E31C0014DA78 /* Pointer_to_an_object_in_heap */,
53+
);
54+
name = Products;
55+
sourceTree = "<group>";
56+
};
57+
DE44A1FE2AF6E31C0014DA78 /* Pointer_to_an_object_in_heap */ = {
58+
isa = PBXGroup;
59+
children = (
60+
DE44A1FF2AF6E31C0014DA78 /* main.cpp */,
61+
);
62+
path = Pointer_to_an_object_in_heap;
63+
sourceTree = "<group>";
64+
};
65+
/* End PBXGroup section */
66+
67+
/* Begin PBXNativeTarget section */
68+
DE44A1FB2AF6E31C0014DA78 /* Pointer_to_an_object_in_heap */ = {
69+
isa = PBXNativeTarget;
70+
buildConfigurationList = DE44A2032AF6E31C0014DA78 /* Build configuration list for PBXNativeTarget "Pointer_to_an_object_in_heap" */;
71+
buildPhases = (
72+
DE44A1F82AF6E31C0014DA78 /* Sources */,
73+
DE44A1F92AF6E31C0014DA78 /* Frameworks */,
74+
DE44A1FA2AF6E31C0014DA78 /* CopyFiles */,
75+
);
76+
buildRules = (
77+
);
78+
dependencies = (
79+
);
80+
name = Pointer_to_an_object_in_heap;
81+
productName = Pointer_to_an_object_in_heap;
82+
productReference = DE44A1FC2AF6E31C0014DA78 /* Pointer_to_an_object_in_heap */;
83+
productType = "com.apple.product-type.tool";
84+
};
85+
/* End PBXNativeTarget section */
86+
87+
/* Begin PBXProject section */
88+
DE44A1F42AF6E31C0014DA78 /* Project object */ = {
89+
isa = PBXProject;
90+
attributes = {
91+
BuildIndependentTargetsInParallel = 1;
92+
LastUpgradeCheck = 1500;
93+
TargetAttributes = {
94+
DE44A1FB2AF6E31C0014DA78 = {
95+
CreatedOnToolsVersion = 15.0.1;
96+
};
97+
};
98+
};
99+
buildConfigurationList = DE44A1F72AF6E31C0014DA78 /* Build configuration list for PBXProject "Pointer_to_an_object_in_heap" */;
100+
compatibilityVersion = "Xcode 14.0";
101+
developmentRegion = en;
102+
hasScannedForEncodings = 0;
103+
knownRegions = (
104+
en,
105+
Base,
106+
);
107+
mainGroup = DE44A1F32AF6E31C0014DA78;
108+
productRefGroup = DE44A1FD2AF6E31C0014DA78 /* Products */;
109+
projectDirPath = "";
110+
projectRoot = "";
111+
targets = (
112+
DE44A1FB2AF6E31C0014DA78 /* Pointer_to_an_object_in_heap */,
113+
);
114+
};
115+
/* End PBXProject section */
116+
117+
/* Begin PBXSourcesBuildPhase section */
118+
DE44A1F82AF6E31C0014DA78 /* Sources */ = {
119+
isa = PBXSourcesBuildPhase;
120+
buildActionMask = 2147483647;
121+
files = (
122+
DE44A2002AF6E31C0014DA78 /* main.cpp in Sources */,
123+
);
124+
runOnlyForDeploymentPostprocessing = 0;
125+
};
126+
/* End PBXSourcesBuildPhase section */
127+
128+
/* Begin XCBuildConfiguration section */
129+
DE44A2012AF6E31C0014DA78 /* Debug */ = {
130+
isa = XCBuildConfiguration;
131+
buildSettings = {
132+
ALWAYS_SEARCH_USER_PATHS = NO;
133+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
134+
CLANG_ANALYZER_NONNULL = YES;
135+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
136+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
137+
CLANG_ENABLE_MODULES = YES;
138+
CLANG_ENABLE_OBJC_ARC = YES;
139+
CLANG_ENABLE_OBJC_WEAK = YES;
140+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
141+
CLANG_WARN_BOOL_CONVERSION = YES;
142+
CLANG_WARN_COMMA = YES;
143+
CLANG_WARN_CONSTANT_CONVERSION = YES;
144+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
145+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
146+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
147+
CLANG_WARN_EMPTY_BODY = YES;
148+
CLANG_WARN_ENUM_CONVERSION = YES;
149+
CLANG_WARN_INFINITE_RECURSION = YES;
150+
CLANG_WARN_INT_CONVERSION = YES;
151+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
152+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
153+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
154+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
155+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
156+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
157+
CLANG_WARN_STRICT_PROTOTYPES = YES;
158+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
159+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
160+
CLANG_WARN_UNREACHABLE_CODE = YES;
161+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
162+
COPY_PHASE_STRIP = NO;
163+
DEBUG_INFORMATION_FORMAT = dwarf;
164+
ENABLE_STRICT_OBJC_MSGSEND = YES;
165+
ENABLE_TESTABILITY = YES;
166+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
167+
GCC_C_LANGUAGE_STANDARD = gnu17;
168+
GCC_DYNAMIC_NO_PIC = NO;
169+
GCC_NO_COMMON_BLOCKS = YES;
170+
GCC_OPTIMIZATION_LEVEL = 0;
171+
GCC_PREPROCESSOR_DEFINITIONS = (
172+
"DEBUG=1",
173+
"$(inherited)",
174+
);
175+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
176+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
177+
GCC_WARN_UNDECLARED_SELECTOR = YES;
178+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
179+
GCC_WARN_UNUSED_FUNCTION = YES;
180+
GCC_WARN_UNUSED_VARIABLE = YES;
181+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
182+
MACOSX_DEPLOYMENT_TARGET = 14.0;
183+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
184+
MTL_FAST_MATH = YES;
185+
ONLY_ACTIVE_ARCH = YES;
186+
SDKROOT = macosx;
187+
};
188+
name = Debug;
189+
};
190+
DE44A2022AF6E31C0014DA78 /* Release */ = {
191+
isa = XCBuildConfiguration;
192+
buildSettings = {
193+
ALWAYS_SEARCH_USER_PATHS = NO;
194+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
195+
CLANG_ANALYZER_NONNULL = YES;
196+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
197+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
198+
CLANG_ENABLE_MODULES = YES;
199+
CLANG_ENABLE_OBJC_ARC = YES;
200+
CLANG_ENABLE_OBJC_WEAK = YES;
201+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
202+
CLANG_WARN_BOOL_CONVERSION = YES;
203+
CLANG_WARN_COMMA = YES;
204+
CLANG_WARN_CONSTANT_CONVERSION = YES;
205+
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
206+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
207+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
208+
CLANG_WARN_EMPTY_BODY = YES;
209+
CLANG_WARN_ENUM_CONVERSION = YES;
210+
CLANG_WARN_INFINITE_RECURSION = YES;
211+
CLANG_WARN_INT_CONVERSION = YES;
212+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
213+
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
214+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
215+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
216+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
217+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
218+
CLANG_WARN_STRICT_PROTOTYPES = YES;
219+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
220+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
221+
CLANG_WARN_UNREACHABLE_CODE = YES;
222+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
223+
COPY_PHASE_STRIP = NO;
224+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
225+
ENABLE_NS_ASSERTIONS = NO;
226+
ENABLE_STRICT_OBJC_MSGSEND = YES;
227+
ENABLE_USER_SCRIPT_SANDBOXING = YES;
228+
GCC_C_LANGUAGE_STANDARD = gnu17;
229+
GCC_NO_COMMON_BLOCKS = YES;
230+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
231+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
232+
GCC_WARN_UNDECLARED_SELECTOR = YES;
233+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
234+
GCC_WARN_UNUSED_FUNCTION = YES;
235+
GCC_WARN_UNUSED_VARIABLE = YES;
236+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
237+
MACOSX_DEPLOYMENT_TARGET = 14.0;
238+
MTL_ENABLE_DEBUG_INFO = NO;
239+
MTL_FAST_MATH = YES;
240+
SDKROOT = macosx;
241+
};
242+
name = Release;
243+
};
244+
DE44A2042AF6E31C0014DA78 /* Debug */ = {
245+
isa = XCBuildConfiguration;
246+
buildSettings = {
247+
CODE_SIGN_STYLE = Automatic;
248+
PRODUCT_NAME = "$(TARGET_NAME)";
249+
};
250+
name = Debug;
251+
};
252+
DE44A2052AF6E31C0014DA78 /* Release */ = {
253+
isa = XCBuildConfiguration;
254+
buildSettings = {
255+
CODE_SIGN_STYLE = Automatic;
256+
PRODUCT_NAME = "$(TARGET_NAME)";
257+
};
258+
name = Release;
259+
};
260+
/* End XCBuildConfiguration section */
261+
262+
/* Begin XCConfigurationList section */
263+
DE44A1F72AF6E31C0014DA78 /* Build configuration list for PBXProject "Pointer_to_an_object_in_heap" */ = {
264+
isa = XCConfigurationList;
265+
buildConfigurations = (
266+
DE44A2012AF6E31C0014DA78 /* Debug */,
267+
DE44A2022AF6E31C0014DA78 /* Release */,
268+
);
269+
defaultConfigurationIsVisible = 0;
270+
defaultConfigurationName = Release;
271+
};
272+
DE44A2032AF6E31C0014DA78 /* Build configuration list for PBXNativeTarget "Pointer_to_an_object_in_heap" */ = {
273+
isa = XCConfigurationList;
274+
buildConfigurations = (
275+
DE44A2042AF6E31C0014DA78 /* Debug */,
276+
DE44A2052AF6E31C0014DA78 /* Release */,
277+
);
278+
defaultConfigurationIsVisible = 0;
279+
defaultConfigurationName = Release;
280+
};
281+
/* End XCConfigurationList section */
282+
};
283+
rootObject = DE44A1F42AF6E31C0014DA78 /* Project object */;
284+
}

‎Learn_CPP_Programming_Deep_Dive/Section 11 OOP/Pointer_to_object_in_heap/Pointer_to_an_object_in_heap/Pointer_to_an_object_in_heap.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>SchemeUserState</key>
6+
<dict>
7+
<key>Pointer_to_an_object_in_heap.xcscheme_^#shared#^_</key>
8+
<dict>
9+
<key>orderHint</key>
10+
<integer>0</integer>
11+
</dict>
12+
</dict>
13+
</dict>
14+
</plist>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// main.cpp
3+
// Pointer_to_an_object_in_heap
4+
//
5+
// Created by George Catalin on 04.11.2023.
6+
//
7+
8+
#include <iostream>
9+
using namespace std;
10+
11+
class Rectangle
12+
{
13+
public:
14+
int length;
15+
int breadth;
16+
17+
int area(){
18+
return length * breadth;
19+
}
20+
21+
int perimeter(){
22+
return 2*(length + breadth);
23+
}
24+
};
25+
26+
int main(int argc, const char * argv[])
27+
{
28+
Rectangle r1;
29+
30+
Rectangle *ptr;
31+
ptr = &r1;
32+
33+
ptr ->length = 20;
34+
ptr ->breadth = 30;
35+
cout<<"The area of this rectangle is "<<ptr->area()<<endl;
36+
cout<<"The perimeter of this rectangle is "<<ptr->perimeter()<<endl;
37+
38+
39+
40+
cout<<"**********************"<<endl;
41+
42+
Rectangle r2; // this object is created on the stack memory
43+
44+
Rectangle *pr2 = new Rectangle(); // this object is created on the heap memory
45+
pr2 -> length = 15;
46+
pr2 ->breadth = 30;
47+
cout<<"The area of the rectangle object created in the heap is "<<pr2 ->area()<<endl;
48+
cout<<"The perimeter of the rectangle object created in the heap is "<<pr2 -> perimeter()<<endl;
49+
50+
delete pr2;
51+
52+
53+
54+
55+
56+
return 0;
57+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /