From 664ccc3ad25f5d20da552899c25b96889e6d6cd1 Mon Sep 17 00:00:00 2001 From: Ceiling_roof Date: Wed, 16 Aug 2023 15:39:42 +0800 Subject: [PATCH 1/3] Committed on or around 2023/08/16 --- Miscellaneous/Cpp/this_keyword_2.java | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Miscellaneous/Cpp/this_keyword_2.java diff --git a/Miscellaneous/Cpp/this_keyword_2.java b/Miscellaneous/Cpp/this_keyword_2.java new file mode 100644 index 0000000..ddbb05c --- /dev/null +++ b/Miscellaneous/Cpp/this_keyword_2.java @@ -0,0 +1,48 @@ +package Cpp; + +class Function_that_returns_objects_2{ + + int value; + + public Function_that_returns_objects_2(int value) { + + this.value = value; + + System.out.println("Inside constructors \n"); + } + + + int get_value() { + return value; + } + + + // Return an object. + Function_that_returns_objects_2 mkBigger() { + + Function_that_returns_objects_2 object = new Function_that_returns_objects_2(value * 2); + + return object; + + } + +} + + + +void display(Function_that_returns_objects_2 ob) { + + System.out.println(ob.get_value()); + +} + + + +public class this_keyword_2 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} From c0b507b57190e18773ffe722cc5a65abbbc4b8f2 Mon Sep 17 00:00:00 2001 From: Ceiling_roof Date: Wed, 16 Aug 2023 15:45:04 +0800 Subject: [PATCH 2/3] Committed on or around 2023/08/16 --- Miscellaneous/Cpp/this_keyword_2.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Miscellaneous/Cpp/this_keyword_2.java b/Miscellaneous/Cpp/this_keyword_2.java index ddbb05c..4988feb 100644 --- a/Miscellaneous/Cpp/this_keyword_2.java +++ b/Miscellaneous/Cpp/this_keyword_2.java @@ -29,7 +29,7 @@ Function_that_returns_objects_2 mkBigger() { } - +// It seems that a function cannot be declared in the global scope. void display(Function_that_returns_objects_2 ob) { System.out.println(ob.get_value()); From 219a4b8c8b2d1d590942331df4a4b3b2bb34ad62 Mon Sep 17 00:00:00 2001 From: Ceiling_roof Date: Wed, 16 Aug 2023 15:46:48 +0800 Subject: [PATCH 3/3] Committed on or around 2023/08/16 --- Miscellaneous/Cpp/this_keyword_2.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Miscellaneous/Cpp/this_keyword_2.java b/Miscellaneous/Cpp/this_keyword_2.java index 4988feb..b20e41e 100644 --- a/Miscellaneous/Cpp/this_keyword_2.java +++ b/Miscellaneous/Cpp/this_keyword_2.java @@ -38,6 +38,14 @@ void display(Function_that_returns_objects_2 ob) { +static void display2(Function_that_returns_objects_2 ob) { + + System.out.println(ob.get_value()); + +} + + + public class this_keyword_2 { public static void main(String[] args) {