Guidelines for writing a test suite
What are the best practices/guidelines for writing test suite for C++ projects? ...
What are the best practices/guidelines for writing test suite for C++ projects? ...
For regular expression \w+\d, in many script language such as perl/python it can be written literally. But in C/C++, I must write it as: const char *re_str = "\\w+\\d"; which is ugly to eye. Is there any method to avoid it? MACRO are also acceptable. ...
When you create some pointers inside the scope of a function, what happens when the function goes out of scope? Do they get destroyed or should I call delete on them at some point? void XMLDocument::AddNode(XMLNode& node) { std::string val = node.GetNodeName(); TiXmlElement* el = new TiXmlElement(val.c_str()); // What about th...
Hello, I want to create a binder service in C++ and be able to bind to that service from java. My question is how? I have mimicked the implementation in frameworks/base/camera/tests/CameraServiceTest/ CameraServiceTest.cpp. It compiles nicely without any warnings and I can run it. But how do I connect to it? The code for the service is...
I need to place several instances of a custom QPushButton subclass adjacent to one another. For some reason, the buttons overlap one another when painted. A simplified example of the problem is below. Here is the (incorrect) output: Here is the code: #include <QtGui> class MyButton : public QPushButton { public: explicit MyButton...
I would like to do some C++ development on Windows using Eclipse and the CDT plugin. I use Eclipse Helios SR1 and have installed the CDT plugin. I have also installed MinGW and now I wrote a simple "Hello World" in Eclipse. hello.cpp #include <iostream> using namespace std; int main() { cout << "Hello World" << endl; return 0; ...
I have a situation in which A has a reference to a class C defined inside B, and C has an instance of class B. When I try to compile the code below, I get "field a has incomplete type". I assume this is because the compiler does not know how much memory it should allocate for an instance of A. class A; class B { public: class C { ...
Hi, I'm looking for a simplest (and fastest) example of TCP socket programming for windows, c or c++, whichever can get it accomplished faster, sending trival data, for example 1 byte, or several bytes, but in one packet. It's for research purposes. I googled and found several examples, however every single of out them looks a bit dif...
Hi everyone, I am currently stumbled into this problem and I'd love to hear some suggestions from you. I have a C++ program that uses a precompiled library to make some queries to PostgreSQL database. Now the problem is I want to find out the total (combined) cpu time it takes to do all routines described in the source code of the prog...
Hello, I am looking at MurmurHash (sites.google.com/site/murmurhash/) I'm using it in a black box kind of a way and not trying to undersatand the maths at this stage. However, I did have a little look at the code and got worried about how it seems to work... Here's the code: uint64_t MurmurHash64A ( const void * key, int len, unsigned...
What are some of your favorite tricks to debug C++ programs with gdb ? Interested in all tricks but also how you call methods (which may be virtual) on objects from within gdb inspecting STL objects (pretty printing them) preventing gdb from going into STL code with continue dealing with inlining, threads, tcmalloc (or custom allocat...
Hi, I'm supporting a customer with strange, very specific mdb access slowdowns. We have a big ( > 100MB) mdb file which is read by our app through ADO, and on some Vista machines (and only on those Vista machines), some, but not all queries take a very long time to execute. The slow query: SELECT * FROM [Table] WHERE [FieldA] = _numbe...
Hi, I have a project that is a library that links against libresolv, It works fine on recent distros: Ubuntu 10.x Fedora 13, Mandriva 2010.1 but on Centos 5.x I get the following errors glibc installed is: glibc-2.5-18.el5_1.1 g++ -DHAVE_CONFIG_H -I. -I./include -I/usr/include/postgresql -O3 -ansi -Wall -Wno-deprecated -D_FORTIF...
Here is the problem. I wrote this function to return a reference to the i element of a member vector, so this element could be edited. Here is the code: Letter& Literal::get (int i) const { return lit_m.at (i); //Vector of Letter objects } But g++ won't let me assign that element to a non-const reference: g++ -o literal.o -c lite...
My code was working fine until I reloaded the program a few hours later. Now I get these this error: error C3867: 'player::getxPos': function call missing argument list; use '&player::getxPos' to create a pointer to member error C3867: 'player::getyPos': function call missing argument list; use '&player::getyPos' to create a poi...
Background: I've implemented a stochastic algorithm that requires random ordering for best convergence. Doing so obviously destroys memory locality, however. I've found that by prefetching the next iteration's data, the performance drop is minimized. I can prefetch n cache lines using _mm_prefetch in a simple, mostly OS+compiler-porta...
I'm reading book of Meyers about effective programming. He is talking about traits classes, I understood that I need them to determine the type of the object during compilation type, but I can't understand his explanation about what are these classes actually do? (from technical point of view) thanks for advance for any explnation of the...
[I globally edited the question to be more "useful" and clear] Hello all, I was wondering about the complexity of the implementation of the function exp in cmath. By complexity, I mean algorithmic complexity if possible. Otherwise cost compared to a floating point operation (addition for example) The following lines : double x = 3; ...
I want to wrap part of the TinyXML library in some custom classes in my project because I only need some of its functionality and I do not wish to expose everything. I have a problem where my XMLDocument::AddNode(...) function is basically doing the same thing that my XMLNode class is meant for. I wondered if anyone could give me som...
Hello, I have, for example, such class: class Base { public: void SomeFunc() { std::cout << "la-la-la\n"; } }; I derive new one from it: class Child : public Base { void SomeFunc() { // Call somehow code from base class std::cout << "Hello from child\n"; } }; And I want to see: la-la-la Hello from child C...