Hi! :)
I have the following problem:
//A.h
class A
{
//...
// this is the important part, i have to call this in the proper way
// in A::SetNewValue(), but i don't know how to do that
protected:
void SetValue(const int* i);
//...
public:
// ??
void SetNewValue(const int* p);
}
the cpp:
//A.cpp
//??
A::SetNe...
My question is closely related to how a DLL exports C++ classes and generic methods (wrt C++ language features without a C# parallel).
I believe you can call functions inside an extern "C" block from C# by just referencing the DLL and using DLLImport. But can you instantiate a templated C++ type? What if the C++ type does somethin' c...
Hello all
I am studying for a C++ test, I have not been able to solve this:
I have data in a int* and I want to print it out to a char*
I thought I could do it the following way:
// pOutputString is of type char*
// pIntegers is of type int*
int pos = 0;
for (int i = 0; i< SIZE; i++)
{
pOutputString[pos] = char(pIntegers[i]);
p...
Hi, Guys:
Today, I encounter a strange problem. My c++ code can work under debug mode.
using g++ -g to compile the code. However, when I use g++ -O to optimize the code. It will stuck somewhere. It seems there is dead looping. Does anybody know how to find this kind of error? When I debug the code with DDD debuger, it works fine. Than...
I have a window with a button that paints the entire window red when clicked, but my code paints the whole window, even the button. When I resize the window or cause the part of the window where the button is to repaint, the button will return. I've only been able to paint the button a solid color after painting the window, but that only...
This may be a stupid question but how does the sizeof operator know the size of an array operand when you don't pass in the amount of elements in the array. I know it doesn't return the total elements in the array but the size in bytes, but to get that it still has to know when the array ends. Just curious as to how this works.
...
Is there a way to import a C# windows form and user control into C++.NET? I'm using VS2008 and have VS2010 installed as well.
...
Suppose I would like to count characters in some mFile like this:
while((c = getc(mFile)) != EOF){
chars[c]++;
}
If I try to show them:
for(int f=0;f<256;f++) {
if(isprint(f) && chars[f]>0)
cout << (char)f << " " << (int)chars[f] << endl;
}
All characters print fine. But if I do
cout << " " << (int)cha...
C++: Using and returning character arrays from functions, return type or reference?
I'm trying to create a null terminated string outside of a function, then run a function which will assign some data to it. For example, char abc [80] is created in main. input() is then run, which will return user input to abc. I figure the two obviou...
I was trying to use a union to so I could update the fields in one thread and then read allfields in another thread. In the actual system, I have mutexes to make sure everything is safe. The problem is with fieldB, before I had to change it fieldB was declared like field A and C. However, due to a third party driver, fieldB must be allig...
Can someone please point me to some documentation on the virtual memory maps used for Linux and Windows. By that I mean what virtual addresses, code, writable static data, the stack and the heap (along with other kernel bits) will normally be placed in, in a typical process?
...
Hi,
Would anyone know how to properly hide classes, methods and properties from intellisense while preserving the ability to call them; and so they do not appear in interop assemblies that are generated from a type library?
I'm writing API hooks for automated testing we don't want exposed to consumers yet. This appears to work well from...
Suppose we have the following problem. We want to read a set of (x, y) coordinates and a name, then sort them in order increasing distance from the origin (0, 0).here is algorithm which use simplest buble sort
#include<iostream>
#include <algorithm>
using namespace std;
struct point{
float x;
float y;
...
I have an ATL ActiveX control that raises three events (Connected, Authenticated, Disconnected) which need to be handled in IE/JavaScript. So far as I can tell, I'm doing everything right, specifically:
(1) I've told ATL to implement the IProviderClassInfo2 interface, as described here.
(2) I've implemented connection points within my...
I am working with a 3rd party C API set in C++ that has two methods of concern for this discussion:
It's equivalent of malloc(): the_api_malloc(size) (plus a matching the_api_free())
A function in which memory created with the_api_malloc() is returned to that takes ownership of it and the_api_free()'s it internally: the_api_give_back(p...
Is there any tool to log the execution path of functions that a program goes through?
I know gdb can show the backtrace at a particular point. But I want to see the whole story of a program. For instance:
int main(){
a();
b();
}
void a(){
c();
}
The tool gives out something like:
a-----
c------
b------
...
Criteria, don't want creating copies of objects all over the place.
Should be fast, memory efficient and should not create leaks.
Should be threadsafe.
Ideally I would want to store pointers to vectors in the HashMap, but I am worried about memory leaks that way.
Is this the best way?
std::map<std::string, std::auto_ptr<std::vector<st...
We are converting a C++ math library to C#. The library mixes the use of floats and doubles (casting between them sometimes) and we are trying to do the same, in order to get the exact same results in C# that we had in C++ but it is proving to be very difficult if not impossible.
I think the problem is one or more of the following, but ...
Hi,
I have a simulation that uses OpenGL for drawing. While it is running, I would like to plot some things on top of my simulation in real time, but every iteration I only want to add few lines to that graph, instead of always re-drawing it from scratch (that would be too costly).
How could I create some surface to which I can always ...
I would like to be able to write something like
char f(char);
vector<char> bar;
vector<char> foo = map(f, bar); //Strikingly functional.
in the STL.
But, as we all know, the STL has the map class as a collection.
Rummaging around, the transform function appears to be similar, but it will not cleverly autogenerate the size of the res...