void main()
{
typedef boost::ptr_map<int, char> MyMap;
//typedef std::map<int, char *> MyMap; // in contrast with std type it works
MyMap mymap;
mymap[1] = new char('a');
mymap[2] = new char('b');
mymap[3] = new char('c');
BOOST_FOREACH(MyMap::value_type value, mymap)
{
std::cout << value.first << " " << value....
In Python there is a maximum recursion depth. Seems it is because Python is an interpreter, not a compiler. Does C++ have the same concept? Or it only connected with RAM limit?
...
Hi,
I am writing Firefox extension which would be compatible with Firefox's 3.0 to 3.6 versions.
I am using nsIDOMNSHTMLElement interface pointer for setting inner text of html element.
I am getting nsIDOMNSHTMLElement interface pointer by calling QI on nsIDOMElement
But IID of nsIDOMNSHTMLElement changes from Firefox's 3.0 to 3.6 ve...
vector<int> l;
for(int i=0;i<10;i++){
l.push_back(i);
}
I want the vector to only be able to store numbers from a specified range (or set).
How can that be done, in general?
In particular, I want to restrict the vector to beonly be able to store single digits.
So, if I do a l[9]++ (in this case l[9] is 9), it should give me an...
Hi All
I have a separate thread ListenerThread having a socket listening to info broadcasted by some remote server. This is created at the constructor of one class I need to develop.
Because of requirements, once the separate thread is started I need to avoid any blocking function on the main thread.
Once it comes to the point of calli...
hello i want to use a texture on a cube (created by glutsolidcube()), how can i define where the texture is pictured at?
(for example on the "frontside" of a cube)
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filterMode);
glTexParameteri(GL_TEXTURE_2...
I need to make a table of identifiers using the method - a combination of a binary tree and hash addressing, but I can not find the information on this method. Could you suggest where I can find information on this method or simple example in C/C++ or another programming language.
.
...
Assuming MyClass uses the default destructor (or no destructor), and this code:
MyClass *buffer = new MyClass[i];
// Construct N objects using placement new
for(size_t i = 0; i < N; i++){
buffer[i].~MyClass();
}
delete[] buffer;
Is there any optimizer that would be able to remove this loop?
Also, is there any way for my code to d...
I have two questions about STL
1) why STL is not thread-safe? Is there any structure that is thread-safe?
2) How to debug STL using GDB? In GDB, how can I print a vector?
...
#include <stdio.h>
#include <string.h>
const int NAMELEN=30;
const int MAXCLASSSIZE=10;
typedef struct StudentRec {
char lastname[NAMELEN];
char firstname[NAMELEN];
long int ID;
int finalmark;
}Student;
I'm new to coding..and I have a question about why there is Student; after the bracket.. is it a format that we hav...
I have a JNI method to access java method which returns an Integer object. I do not want to return the primitive int type because this code will be modified to handle Generic objects. The following is what I have. I am not able to get the value of the Integer that I pass. The output at C++ side is something like
value = 0x4016f3d0
Ho...
I have to link dynamically with OpenSSL libeay32.dll.
I'm writing native c++ console application using Visual C++ Express 2008.
I'm including a header evp.h from OpenSSL distribution. Building and...:
error LNK2001: unresolved external symbol _EVP_aes_256_cbc
error LNK2001: unresolved external symbol _EVP_DecryptInit
error LNK2001: un...
This has been plaguing me for weeks. It's something really simple, I know it. Every time I print a singly linked list, it prints an address at the end of the list.
#include <iostream>
using namespace std;
struct node
{
int info;
node *link;
};
node *before(node *head);
node *after(node *head);
void middle(node *head, node *ptr);
v...
I want to provide a virtual webcam via DirectShow that will use the video feed from an existing camera running some tracking software against it to find the users face and then overlay a 3d model oriented just that it appears to move the users face. I am using a third party api to do the face tracking and thats working great. I get pos...
hello,
in c++ you can put a member in a base class and a member with the same name in the inherited class.
how can i access a specific one in the inherited class?
thanks!
...
I thought the NetGetJoinInformation() function might provide the name of the AD Domain a Workstation is a member of but it only provides the domain name in pre-windows 2000 (Netbios) format.
For example if the full name of the AD domain is TestDomain.Lan then NetGetJoinInformation() returns TESTDOMAIN as the domain name.
Need a fu...
We have a server (Java EE) application, it will do some image processing jobs based on user request. Such as convert image format (e.g. TIFF to JPEG), convert image color (e.g. RGB to Gray to BW), resample (resize) image. Some customer from printing industry use very large image, such as 2000 dpi, 6 * 8 inch, 4 color components, which wi...
The following code will give a hard fail when run under Windows 7 32bit:
void CTestView::OnDraw(CDC* /*pDC*/)
{
*(int*)0 = 0; // Crash
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
// TODO: add draw code for native data here
}
However, if I try this on Windows 7 64bit, I just get ...
So I'm pretty new to Qt, and I've just inherited a project from someone else who is also new to Qt. He isn't around this week btw. We are using Visual Studio 2008, and have the latest version of Qt installed(4.6.2).
The project builds on my coworker's machine fine, and I can get the project from svn and build it directly. But under a...
In a comparison operator:
template<class R1, class R2>
bool operator==(Manager<R1> m1, Manager<R2> m2) {
return m1.internal_field == m2.internal_field;
}
Is there any way I could enforce that R1 and R2 must have a supertype or subtype relation? That is, I'd like to allow either R1 to be derived from R2, or R2 to be derived from R...