Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I wanted to know what jobect is? I know it is opaque structure. But how can we access fields of an object using an opaque structure?
When we call a function, using a function pointer (for example GetMethodID), What is ID of a method? how are we we getting the id of a method? What exactly is it's return type. I know it's jmethodID, but what is jmethodID?
I wanted to know what jobect is? I know it is opaque structure.
Correct.
But how can we access fields of an object using an opaque structure?
You can't.
When we call a function, using a function pointer (for example GetMethodID)
There is no function pointer there, except GetMethodID itself.
What is ID of a method?
It's an opaque quantum that permanently identifies the method. You don't need to know anything else about it.
how are we we getting the id of a method?
By calling GetMethodID().
What exactly is it's return type. I know it's jmethodID, but what is jmethodID?
It's whatever it says it is in jni.h. You don't have any reason for needing any more information than that.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
I'm learning SDL right now and I'm trying to use timer callback function.
The function SDL_AddTimer() offer me only one argument to pass through but I want to pass different types of variables into it.
(https://wiki.libsdl.org/SDL_AddTimer)
I think of one solution is that I can declare a structure containing all of my variables but I'm not sure if it is the best way to do so.
Thank you for your help ~~
I think of one solution is that I can declare a structure containing all of my variables but I'm not sure if it is the best way to do so.
Yes this is the correct and best way to pass parameters whenever you are presented with a callback that accepts void*. Then cast back to the struct type from inside the callback.
Same thing goes when using pthreads/Windows threads or other such common APIs.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
For example, I have my class employee. I want to keep record how many employees till date have worked for me. I can make static count variable and add 1 in my constructor. But whenever my temporary object will be created when we pass object in parameters or return object of our class it will add for them too.
Static class member is the right way to go. A few things to be careful about:
Make sure you overload all constructors. The ones you don't want to support you should explicitly delete.
Don't forget to decrement in destructor.
If this program of yours is multithreaded then use atomic_uint or provide locking mechanism of your own.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to make a function that has one parameter (a string that contains the name of a variable in my program) and returns the value that the variable stores.
Unfortunately, C++ doesn't provide a simple mechanism for reflection (the idea that the program can, at runtime, look up variable names by value or the like). You may need to consider using an alternate approach.
For example, you could make a std::unordered_map whose keys represent certain values that you'd like to look up and whose values are populated with the items you'd like to look up.
Hope this helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to pass values from qml to set function written in Qt cpp, the values that will be passed is of different data types, example int or string, I will be writing only one set function in cpp which will take this values and return Qstring or int or double.How can I write a code for this.
C++ does know of two types:
QVariant
QJSValue
which might be the value, that you passed... That depends on you.
Both of them have various methods to test for their content, and to convert to this.
See the linked documentations for this.
You may even store the passed value as the corresponding type, without the need of conversion (up to the time, you need it for calculations in C++) It depends on, what you will do with it, to find the right choice.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Im trying to do a pointer to pointer to a dynamic array that his elements will be a pointer to "figurasGeom"
How can I do it? I started with the pointer to pointer but Im not sure if that is ok..
figuraGeom ** lista;
Is there another way to make a dynamic array without using "vector"?
I have something like this but I dont know how to implement it
figuraGeom* vectr [];
Thank you in advance!
Based on your description, you left the vector part out, so you would need something like this:
vector<figuraGeom*> **lista;
But this is a really weird data representation, at least in C++. You should start working more with higher-level containers and/or smart pointers in C++.