What is the best way to measure the memory used by a C++ program or a block in a C++ program. The measurement code should thereby be part of the code and it should not be measured from outside. I know of the difficulty of that task, so it does not have to be 100% accurate but at least give me a good impression of the memory usage.
...
What's the meaning of #line in C language? Where would it be used?
...
Hi,
I want to load managed assembly into the AppDomain from native c++ code.
If it worth something the native code is a CLR profiler so I get notification each time AppDomain is created.
...
I love Haskell style pattern matching.
I have my C++ code as follows:
ObjectPtr ptr;
if(ptr.isType<Foo>()) { // isType returns a bool
Ptr<Foo> p = ptr.convertAs<Foo>(); // convertAs returns a Ptr<Foo>
......
}
if(ptr.isType<Bar>()) {
Ptr<Bar> p = ptr.convertAs<Bar>();
......
}
Now, are there any macros I can do define to simp...
Here is the code:
#include <vector>
#include <iostream>
class A
{
public:
A() { std::cout << __FUNCTION__ << "\n"; }
~A() { std::cout << __FUNCTION__ << "\n"; }
A& operator=(const A&) { std::cout << __FUNCTION__ << "\n"; return *this;}
};
int main(int argc, char* argv[])
{
std::vector<A> as;
A a;
as.push_back(...
Hi guys! I've absolutely no idea why my delete codes inside the destructor won't be able to functionally well. I hope u guys can help me for this.
Thank you so much!
class Array2D
{
public:
Array2D();
Array2D(int, int);
~Array2D();
private:
int row;
int col;
int **p;
};
Array2D::Arra...
Hi,
if a function return an int, can it be assigned by an int value? I don't see it makes too much sense to assign a value to a function.
int f() {}
f() = 1;
I noticed that, if the function returns a reference to an int, it is ok. Is it restricted only to int? how about other types? or any other rules?
int& f() {}
f() = 1;
Than...
Hi guys! I was given a question from my prof. that to use a void pointer to create a dynamic 2D array rather than int pointer due to the data type is more general.
But I've no idea how to create by using -> void***m // data type is void* pointer
Anyone can give an example on this? Appreciate your answer, many thanks!
...
Hi. I'm writing a cross-platform Qt-based program that from time to time needs to play back audio supplied externally (outside my control) as raw PCM. The exact format is 16 bit little-endian PCM at various common sample rates.
My first obvious idea was to use Qt's own Phonon for audio playback, but there are two problems with this appr...
0xC0000005: Access violation reading location 0xcccccccc.
printf is throwing this exception.
I don't know why this is happening...
There are values in those string variables. Am I using printf wrong?
Help! (Please see the switch case)
string header;
string body;
string key;
if (!contactList.isEmpty()) {
cout << "Enter conta...
Hi everyone,
I have to code a Pac-Man clone in C++ for a school project, and I'm hesitating between SDL and Qt for the graphical implementation.
I have already a little experience with SDL, but I wanted to give Qt a try. I was asking myself if it is "technically" realisable and if Qt is a good choice for that. I know that it have an an...
i'm using a glutTimerFunc(...) to achieve motion of robot arm, my problem is left side 0 degree to 90 is easily done,
when i try 0 to -90 degree, the arm is not stoping? i tried various methods, but all falied, can you suggest better options?
here's my timer function, void myTimerFunc(int var)
{
switch(var)
{
case 1: if(shoulder>=90)
...
Given 2N-points in a 2D-plane, you have to group them into N pairs such that the overall sum of distances between the points of all of the pairs is the minimum possible value.The desired output is only the sum.
In other words, if a1,a2,..an are the distances between points of first, second...and nth pair respectively, then (a1+a2+...an...
I'm looking for an easy, cross platform way to join path, directory and file names into a complete path in C++. I know python has os.path.join() and matlab has fullfile(). Does Qt has something similar? QFileInfo doesn't seem to be able to do this.
...
hi
I'm trying to setup ECB to work with C++ sources.
seemingly, semantic or ECB has problem determining whenever a function declarant with explicit namespace, namespace:: function , is really in the namespace. instead it parses it as struct member function.
Moreover, typedef is parsed as function prototypes.
What should I do to fix it...
Apparently there is a “malloc_allocator” provided with gcc for use with STL. It simply wraps malloc and free. There is also a hook for an out-of-memory handler. Where can I find more about it? Where can I find its header file? I’m using gcc 4.x.
...
There is something I have never understood. How can a great big PC game like GTA IV use 50% of my CPU and run at 60fps while a DX demo of a rotating Teapot @ 60fps uses a whopping 30% ?
Thanks
...
Let's say I have an array like this:
string x[2][55];
If I want to fill it with "-1", is this the correct way:
fill(&x[0][0],&x[2][55],"-1");
That crashed when I tried to run it. If I change x[2][55] to x[1][54] it works but it doesn't init the last element of the array.
Here's an example to prove my point:
string x[2][55];
...
I want to make a global vector of my own object class called "Person". However, the compiler says that
error C2039: '{dtor}' : is not a member of 'System::IDisposable'
1> c:\windows\microsoft.net\framework\v2.0.50727\mscorlib.dll : see declaration of 'System::IDisposable'
So I looked up how to implement IDisposable (which I...
I have a C++ program that I compile with mingw (gcc for Windows). Using the TDM release of mingw which includes gcc 4.4.1. The executable links to two static library (.a) files: On of them is a third-party library written in C; the other is a C++ library, written by me, that uses the C library provides my own C++ API on top.
An (in m...