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

Latest commit

 

History

History
History
122 lines (88 loc) · 2.79 KB

File metadata and controls

122 lines (88 loc) · 2.79 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package chapter09;
/*
public class Snippet {
// VariableReferenceEx1.cpp
// Example of using reference in C++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello world!" << endl;
int x= 10, y = 100; // variable declaration
int & j= x; // j is a reference declaration;
// j reference to variable "x"
//int & k = 100; // is NOT valid
cout << "Variable x = " << x << endl;
cout << "Address of variable x, &x = " << &x << endl;
cout << "Reference j = " << j << endl;
cout << "Address of reference j, &j = " << &j << endl;
cout << "&j + 1 = " << &j+1 << endl;
return 0;
}
}
*/
public class Snippet {
//CallByValueEx1.cpp
#include <iostream>
using namespace std;
int CallByValue(string ); // Function with a variable argument
int main() {
string myname = "Mahdi"; // myname is a local variable
cout << "Initially, inside main(), Name = " << myname << endl;
CallByValue(myname);
cout << "After calling CallByValue(), Name = " << myname << endl; // Look here ??!!??
cout << endl ;
cout << "Now, inside main(), Name = " << myname << endl;
return 0;
}
int CallByValue(string newname ) // newname is a parameter (local variable) here
{
newname = "Mahdi Munim";
cout << "Inside CallByValue(), Name = " << newname << endl;
return 0;
}
//CallByRefEx1.cpp
//CallByRefEx1.cpp
#include <iostream>
using namespace std;
int CallByRef(string& ); // Function with a reference argument
int main() {
string myname = "Mahdi"; // myname is a local variable
cout << "Initially, inside main(), Name = " << myname << endl;
CallByRef(myname);
cout << "After calling CallByRef(), Name = " << myname << endl; // Look here ??!!??
cout << endl;
cout << "Now, inside main(), Name = " << myname << endl;
return 0;
}
int CallByRef(string& newname ) // newname is a reference here
{
newname = "Mahdi Munim";
cout << "Inside CallByRef(), Name = " << newname << endl;
return 0;
}
/* NativeMe.cpp */
/* This Program define body of the Native Method */
#include<jni.h> //From jdk1.3\include
#include<NativeMe.h> //From Current Directory
#include<stdio.h> //From Included Directory
JNIEXPORT void JNICALL Java_NativeMe_test(JNIEnv *env, jobject obj)
{
jclass cls;
jfieldID fid;
jint i;
cout<<"\tLoading the native method....." <<endl;
cls = (*env)->GetObjectClass(env, obj);
fid = (*env)->GetFieldID(env, cls, "i", "I");
if(fid ==0)
{
cout<<"Could not found get field!" <<endl;
return;
}
i = (*env)->GetIntField(env, obj, fid);
cout<<"Inside the test() Before Changing i = << i << endl;
(*env)->SetIntField(env, obj, fid, i*2);
cout<<"Inside the test() After Changing i = << i << endl;
cout<<"\tEnding the native method....." <<endl;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.