Hey everyone, considering the following code (compiled with g++ -lpthread thread_test.cpp) how can I know what number thread I am in from inside "thread_function"? And let me know if you have any other suggestions.
Thanks!
thread_test.cpp:
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
class A {
p...
I'm getting this same error, but I've checked to make sure the properties were set correctly in the .h file.
Here's the code:
NSUInteger theSizesCount = [theWho.theSizes count];
The error is "error: request for member theSizes in something not a strucutre or union. This .m file is importing 6 .h files, and 4 of them have the same prop...
I used to write this:
Private Sub Example()
Static CachedPeople As List(Of MyApp.Person)
If CachedPeople Is Nothing Then
CachedPeople = New List(Of MyApp.Person)
End If
...rest of code...
End Sub
But then wondered if I could reduce this to:
Private Sub Example()
Static CachedPeople As New List(Of MyApp.Person)
...rest of code...
...
I want to access a private data member in a class. There is no member function in the class to access the private data member. It is private.
I want to take the class and some how crack it open. One method was to copy the declaration of the class, make the private member public and call the new class class something_else. Then I do a r...
I'm writing a equals(Object obj) function for a class. I see that it is possible to access the private fields of obj from the caller. So instead of using a getter:
Odp other = (Odp) obj;
if (! other.getCollection().contains(ftw)) {
}
I can just access the field directly:
Odp other = (Odp) obj;
if (! other.collection.contains(ftw)) {...
How should I write my code to example a specific array index of an array that happens to be a member of a structure? The following code is giving me problems.
// main.c
void clean_buffers(void); // prototype
struct DEV_STATUS {
unsigned char ADDR;
unsigned char DEV_HAS_DATA;
unsigned char ETH_HAS_DATA;
unsigned char D...
Hi
I am developing an web application using php.
One of the requirement is the want member id looks like folder name such as
http......com//joe
The id is "joe"
Normally i will use http......com/?id=joe but my client don't what this idea...
How do i grab that id???
Thanks
...
Is there a better method to establish the positional offset of an object's data member than the following?
class object
{
int a;
char b;
int c;
};
object * o = new object();
int offset = (unsigned char *)&(object->c) - (unsigned char *)o;
delete o;
...
How can I do this? (The following code does NOT work, but I hope it explains the idea.)
class MyClass
{
....
private:
int ToBeCalled(int a, char* b);
typedef (MyClass::*FuncSig)(int a, char* b);
int Caller(FuncSig *func, char* some_string);
}
I want to call Caller in some way like:
Caller(ToBeCalled, "stuff"...
I have a class member myMember that is a myType pointer. I want to assign this member in a function that is declared as const. I'm doing as follows:
void func() const
{
...
const_cast<myType*>(myMember) = new myType();
...
}
Doing this works fine in VC++, but GCC gives an error with the message "lvalue required as left ...
I'm not sure if non-static public member active patterns are allowed but you can define them without the compiler complaining. If they are allowed what's the syntax for matching against one? The compiler is giving me a type mismatch for Foo in FooBar2.doSomething. Expecting a 'a -> Choice<'b,'c> given 'a -> 'd -> Choice<unit,unit>
// N...
I would like to iterate through members of any class in a referenced library much like is done using the Object Browser. How can this be done using VBA?
...
Hi all,
I've got a lightweight templated class that contains a couple of member objects that are very rarely used, and so I'd like to avoid calling their constructors and destructors except in the rare cases when I actually use them.
To do that, I "declare" them in my class like this:
template <class K, class V> class MyClass
{
publi...
Let's say that I create an instance of class B, which has an static variable x, assigned with a value of 3 in the class B declaration. In the main() method, I do this:
B b = new B();
b.x = 7; //allowed to use an instance to set the static member value
After this, b is serialized and then de-serialized. Then, the following line occurs:...
I have the following class in PHP
class MyClass
{
// How to declare MyMember here? It needs to be private
public static function MyFunction()
{
// How to access MyMember here?
}
}
I am totally confused about which syntax to use
$MyMember = 0; and echo $MyMember
or
private $MyMember = 0; and echo $MyMember
or
$this->My...
I have a class CContainer that has some members CMemberX, CMemberY, which are independent of each other and other CClientA, CClientB classes that use CContainer.
#include "MemberX.h"
#include "MemberY.h"
class CContainer
{
public:
CMemberX & GetX() const { return m_x; }
CMemberY & GetY() const { return m_y; }
private:
CMem...
Hey, I think I have the wrong idea here, but I'm not sure what is best. I want a class with a member variable that can be of any type, depending on what is needed at the time. So far, I have something like this:
public class ConfigSetting<T> {
private T value;
public T GetValue() {
return value;
}
public voi...
Hi, I have this as one of my members of the class 'KeyEvent':
private delegate void eventmethod();
And the constructor:
public KeyEvent(eventmethod D) {
D();
}
What I want to do is instead of calling D() there, I want to store that method (D) as a member variable of KeyEvent, so something like:
stored_method = D();...
Hello, I have this interface
public interface TestInterface
{
[returntype] MethodHere();
}
public class test1 : TestInterface
{
string MethodHere(){
return "Bla";
}
}
public class test2 : TestInterface
{
int MethodHere(){
return 2;
}
}
Is there any way to make [returntype] dynamic?
...
Hello!
Let's we have a simple structure (POD).
struct xyz
{
float x, y, z;
};
May I assume that following code is OK? May I assume there is no any gaps? What the standard says? Is it true for PODs? Is it true for classes?
xyz v;
float* p = &v.x;
p[0] = 1.0f;
p[1] = 2.0f; // Is it ok?
p[2] = 3.0f; // Is it ok?
...