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

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions 28 Miscellaneous/Cpp/Pointer_to_object.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package Cpp;

class P_example {
private int num;

void set_num(int val) {
num = val;
}

void show_num() {
System.out.println(num);
}
}

public class Pointer_to_object {

public static void main(String[] args) {
// TODO Auto-generated method stub

P_example objectives[] = new P_example[2];
objectives[0].set_num(10);
objectives[1].set_num(20);

objectives[0].show_num();

}

}
30 changes: 30 additions & 0 deletions 30 Miscellaneous/Cpp/Pointer_to_object2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package Cpp;

class P_example2{
private int num;

void set_num(int val) {
num = val;
}

void show_num() {
System.out.println(num);
}
}

public class Pointer_to_object2 {

public static void main(String[] args) {
// TODO Auto-generated method stub

int[] array_of_integer = new int[5];

P_example2[] objectives = new P_example2[2];

objectives[0] = new P_example2();
objectives[0].set_num(10);
objectives[0].show_num();

}

}
30 changes: 30 additions & 0 deletions 30 Miscellaneous/Cpp/Pointer_to_object3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package Cpp;

class P_example3{
private int num;

void set_num(int val) {
num = val;
}

void show_num() {
System.out.println(num);
}
}

public class Pointer_to_object3 {

public static void main(String[] args) {
// TODO Auto-generated method stub

P_example3 objective[] = {new P_example3(), new P_example3()};

objective[0].set_num(10);
objective[0].show_num();

objective[1].set_num(20);
objective[1].show_num();

}

}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.