diff --git a/Miscellaneous/Cpp/this_keyword_2.java b/Miscellaneous/Cpp/this_keyword_2.java new file mode 100644 index 0000000..b20e41e --- /dev/null +++ b/Miscellaneous/Cpp/this_keyword_2.java @@ -0,0 +1,56 @@ +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; + + } + +} + + +// 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()); + +} + + + +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) { + // TODO Auto-generated method stub + + } + +}