This might be a GDB question.. but I'd like to run my app in the debugger and have the debugger break when an exception is thrown, so I can see where the code is and what its doing at that time.
I do this often in Visual Studio using the Debug -> Exceptions dialog, checking the 'Thrown' column beside the type of exceptions I'd like to s...
This is a rather old topic: Are setters and getters good or evil?
My question here is: do compilers in
C++ / D / Java
inline the getters and setter?
To which extent do the getters/setters impact performance (function call, stack frame) compared to a direct field access. Besides all the other reasons for using them, I would like to know...
I am curious as to what part of the dereferencing a NULL ptr causes undesired behavior. Example:
// #1
someObj * a;
a = NULL;
(*a).somefunc(); // crash, dereferenced a null ptr and called one of its function
// same as a->somefunc();
// #2
someObj * b;
anotherObj * c;
b = NULL;
c->anotherfunc(*b); // dereferen...
I have a memory block that is divided into a series of location that can be retrieved and returned by client code.
The method that returns locations back looks like this:
void ReturnLocation(void *address) {
int location = AddressToLocation(address); // I need the location here
// some code
DoSmthA(location);
}
void DoSmth...
I'm writing an application intended for distribution around the world. I recently discovered a method of WinHTTP:
http://msdn.microsoft.com/en-us/library/aa384097(VS.85).aspx
This can decode any Netscape-style PAC file (in Javascript) and tell me the correct proxy to use for any URL I might want to use.
That's all great, but I've not...
I am trying to learn C++ via some web tutorials. I don't have a compiler available to me, otherwise I would try this out. I'm not sure what is meant by a const pointer. Does that just mean it always points to the same memory address? Why would you ever want to do that? Would the following code be legal?
...
int * const aPointer = ne...
Within the same compilation unit, the C++ standard says that static initialization order is well defined -- it's the order of the declarations of the static objects. But using the Sun Studio 12 compiler I'm encountering unintuitive behavior. I've define a templated class helper<T> which contains a static member _data of type T and a stat...
Whenever I want to modify a winform from another thread, I need to use
->Invoke(delegate, params)
so that the modification occurs in the winform's own thread.
For every function that needs to modify the gui, I need another delegate function.
Is there some scheme which allows me to limit the number of delegate functions needed? I have...
I have a std::vector. I want to create iterators representing a slice of that vector. How do I do it. In psudo C++:
class InterestingType;
void doSomething(slice& s) {
for (slice::iterator i = s.begin(); i != s.end(); ++i) {
std::cout << *i << endl;
}
}
int main() {
std::vector v();
for (int i= 0; i < 10; ++i) {...
I'm writing a program where the user inputs names and then ages. The program then sorts the list alphabetically and outputs the pairs. However, I'm not sure how to keep the ages matched up with the names after sorting them alphabetically. All I've got so far is...
Edit: Changed the code to this -
#include "std_lib_facilities.h"
struct...
I have a performance intensive routine that is written in PHP that I'd like to port to C++ for a performance increase. Is there any way to write a plugin or extension or something using C++ and interface with it from PHP? WITHOUT manually editing the actual PHP source?
...
I have a DLL made in C#, this DLL contains some clases like Creator.
I need to load this DLL and use Creator class in C++ unmanaged,
so Is there some way to create that instance or must I load just the functions exposed?
I need something like this:
CreatorInstance->Init();
Is this posible?
...
How do people normally manage copying a list of large objects around?
Here's my situation:
Currently I have this:
typedef std::vector<float> Image;
and I'm storing it in a
std::list<Image> lst;
The Image.size() is quite large (each is ~3-5 MB).
I'm passing (copying) the list around.
Is it a correct understanding on my part that...
My program opens a socket on port 80, but if I don't run it as root (with sudo) then it fails to open the socket with a permission error.
This means my application doesn't work when I launch it in the debugger.
So:
Can I tell Eclipse-CDT somehow to launch the app using sudo?
Or, can I somehow enable my program to have permission to o...
I'm writing a C++ program which needs to be able to read a complex and esoteric file type. I already have a Java program for handling these files which includes functionality to convert them into simpler file formats. My idea is, whenever my program needs to read info from a complex file, to have it call the Java method to convert it t...
I created a vector out of a struct to store multiple types of values. However, I can't get input to work.
#include "std_lib_facilities.h"
struct People{
string name;
int age;
};
int main()
{
vector<People>nameage;
cout << "Enter name then age until done. Press enter, 0, enter to continue.:\n";
People name;
...
Hi,
Is there a way to reduce the capacity of a vector ?
My code inserts values into a vector (not knowing their number beforehand), and
when this finishes, the vectors are used only for read operations.
I guess I could create a new vector, do a .reseve() with the size and copy
the items, but I don't really like the extra copy operati...
Hello,
I'm using C++Test from Parasoft for unit testing C++ code.
I came across the following problem. I have a function similar to the next one (pseudocode):
bool LoadFileToMem(const std::string& rStrFileName)
{
if( openfile(rStrFileName) == successfull )
{
if( get_file_size() == successfull )
{
i...
While investigating the D language, I came across GDC, a D Compiler for GCC. I downloaded the version for MinGW from here:
http://sourceforge.net/projects/dgcc/files/
Documentation was almost nonexistent, but it did say that most of the command line switches were the same as for the GCC compiler. However, that doesn't help me much, s...
This is driving me mad for the past 1.5 hrs, I know it's a small thing but cannot find what's wrong (the fact that it's a rainy Friday afternoon, of course, does not help).
I have defined the following class that will hold configuration parameters read from a file and will let me access them from my program:
class VAConfig {
friend...