Hi,
I have a code a following (simplified version):
#define MESSAGE_SIZE_MAX 1024
#defined MESSAGE_COUNT_MAX 20
class MyClass {
public:
.. some stuff
private:
unsigned char m_messageStorage[MESSAGE_COUNT_MAX*MESSAGE_SIZE_MAX];
};
I don't like defines, which are visible to all users of MyCalss.
How can I do it in C++ style?
...
I have a struct:
struct OutputStore
{
int myINT;
string mySTRING;
}
If I create an array of type OutputStore as follows:
OutputStore *OutputFileData = new OutputStore[100];
then I can address it with:
OutputFileData[5].myINT = 27;
But if I use a vector instead of an array:
vector<OutputStore> *OutputFileData = new vect...
I use gdb (actually DDD), and getting an element out of container is impossible. So I typically end up rolling my own loop for debugging purposes...
What do you do?
...
I link my C++ code against several libraries (a couple of which are heavily header-based), some of which haven't been updated in a while. I've been compiling my code with -Wall and Wextra on GCC 4.0 for a while with no warnings or errors. However, now that I'm using a newer version of GCC (4.3), a number of my files have been printing wa...
Note that I can conduct the research inside the boost source code, and may do this to answer my own curiosity if there isn't anyone out there with an answer.
I do ask however because maybe someone has already done this comparison and can answer authoritatively?
It would seem that creating a shared memory mapped file between processes, ...
I'm learning C++ with this book of Deitel: C++ How to Program, 5/e and some tutorials and resources of the internet, but I want to learn how I can develop Nintendo GameBoy Advance games using C++, but only in resources over the internet, because I don't want to spent money now with a thing that I only want to try.
...
Hi there,
In my application I am creating an object pretty much like this :
connect() {
mVHTGlove = new vhtGlove(params);
}
and once I am about to close application I call this one :
disconnect() {
if (mVHTGlove)
delete mVHTGlove;
}
This call always triggers a breakpoint with the following message :
Windows has trigg...
A C++ compiler that I will not name lets you take the address of a literal, int *p =
Clearly 42 is an r-value and most compilers refuse to do so.
Why would a compiler allow this? What could you do with this other than shoot yourself in the foot?
...
I need to retrieve process information in a C/C++ program. I need at least basic things like CPU% and memory usage, but additional details would be useful as well.
The problem is that I need to use this information in a portable program, that will run on multiple platforms: windows, linux, MAC and possibly Solaris too.
Is there a libra...
When, if ever, can delete and free be used interchangeably in C++?
My concern is as follows: Say there is an incorrect mixup in the use of malloc/free and
new/delete (not to mention new[]/delete[]). However delete and free doing the same thing
fortuitously so this goes uncaught in testing. Later this may lead to a crash in production.
...
Possible Duplicates:
Why should we typedef a struct so often in C?
Difference between struct and typedef struct in C++?
What is the difference between the following type declarations?
struct Person
{
int age;
};
typedef struct
{
int age;
}Person;
I understand that
struct
{
int age;
}Person;
Creates and ...
I have the following code (sorry for the large code chunk, but I could not narrow it down any more)
template <bool B>
struct enable_if_c {
typedef void type;
};
template <>
struct enable_if_c<false> {};
template <class Cond>
struct enable_if : public enable_if_c<Cond::value> {};
template <typename X>
struct Base { enum { value ...
Without attempting to bind it
...
Hi,
I have some native code which returns a jbyteArray (so byte[] on the Java side) and I want to return null. However, I run into problems if I simply return 0 in place of the jbyteArray.
Some more information:
The main logic is in Java, the native method is used to encode some data into a byte stream. don;t ask.. it has to be done li...
I have a code library written in plain old C++ (no .NET/managed code) and I'm porting the application that uses this code to C#. I'm faced with two options:
Rewrite the C++ code in C# to achieve the same functionality;
Compile the C++ as a DLL and use it as a library in the C# application.
I'm relatively new to C# and am pretty unfam...
In Windows I can use Shell_NotifyIcon(). What is the linux equivalent of this function?
Is it different in GNOME (gtk) and KDE (qt)? Can't find any tutorials in the Internet.
...
I am trying to create a simple ray tracer. I have a perspective view which shows the rays visibly for debugging purposes.
In my example screenshot below I have a single white sphere to be raytraced and a green sphere representing the eye.
Rays are drawn as lines with
glLineWidth(10.0f)
If a ray misses the sphere it is given color glC...
Hi,
I'm building a cmake based build system for our product. The problem is that Visual Studio project, generated by cmake, doesn't display header files in solution browser.
What I need to add in CMakeList.txt to list header files?
The preferred solution is where no need to list each particular header file.
Solution
Here is a solution...
Possible Duplicate:
Debugging techniques
How can I improve my debugging skills? I am thinking in the context of C++ under UNIX, C#, and in general.
Please suggest how I can improve in these areas in terms of:
Approaches to take, where to start, and how to proceed.
Tools to use, and how use them effectively.
Recommended materi...
I just made a Swap routine in C# like this:
static void Swap(ref int x, ref int y)
{
int temp = x;
x = y;
y = temp;
}
It does the same thing that this C++ code does:
void swap(int *d1, int *d2)
{
int temp=*d1;
*d1=*d2;
*d2=temp;
}
So are the ref and out keywords like pointers for C# without using unsafe code...