In a program to simulate logic gates I switched from using arrays
node N[1000];
to vectors
vector<node> N;
And my program did work perfectly before using vectors but now it prints wrong results, so I tried debugging and I found out that the bug happens here:
node* Simulator::FindNode(string h)
{
int i;
for(i = 0; i < NNo...
I want to derive from std::back_insert_iterator to create a kind of filter for a string type, say back_xml_insert_iterator, that will examine the characters passed through it looking for characters that can not be emitted "naked" into an XML stream, e.g., '"', '&', '<', '>', and '\'', and will on-the-fly insert their character entity ref...
Does anyone know a very simple physics engine, or just a set of basic functions that could complete these tasks: Simple point, line, and rectangle collision detection? I looked at Box2D but it is way too advanced for what I am making. I just need some simple code. Thanks in advance!
...
do i need virtual destructor when iam using boost::ublas matrix ? btw my class is a template class
...
I have started using codelite as my c++ development IDE on Linux. I wanted to compile one of the makefile based project that I have. The directory structure of the project source code is this:
src
dirA
dirC
c.cpp
a.cpp
dirB
b.cpp
Makefile
Now when I do import files from directory, I have to check box each direc...
I want to make an application, but the application will be using icons (bitmaps) for some of the menu buttons and other stuff. I want to keep my application as one simple, single standalone exe file which means I will somehow have to embed all of the icons into the application (EXE on windows) so I can load the bitmaps without having any...
short -- Is it possible to build a external binary/library out of a project with CMake, when the binary/library only has a makefile given?
So you have your own project, a bunch of CMakeLists.txt in your src-tree and this external library with its source-files. Your sources depend on this library and some binaries/libraries want to link ...
Say I have strings like these:
bunch of other html<a href="http://domain.com/133742/The_Token_I_Want.zip" more html and stuff
bunch of other html<a href="http://domain.com/12345/another_token.zip" more html and stuff
bunch of other html<a href="http://domain.com/0981723/YET_ANOTHER_TOKEN.zip" more html and stuff
What is the regular exp...
Couldn't figure out how to word the question accurately, so here's an example:
Given this function prototype:
void Foo(myClass* bar);
I want to prevent this usage:
Foo(new myClass());
and instead require a previously created object:
myClass* bar = NULL;
bar = new myClass();
Foo(bar);
or
myClass bar;
Foo(&bar);
Thanks.
EDI...
For a class X and a QSet< X* >, how is it possible to make sure that the QSet doesn't contain duplicate elements?
The unique property in each object of type X is a QString that can be fetched using getName().
I've implemented the qHash(X*) function, the operator==(), operator<() and operator>(), but the QSet still accepts duplicate elem...
ok i just upgrade it to visual studio c++ 2010 express. when i use gdi+ i get errors not in my file but in the gdi+ header file
one of the errors is this
c:\program files (x86)\microsoft sdks\windows\v7.0a\include\gdiplusimaging.h(74): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
here is the ...
The Qt documentation "Mac Differences" page provides the following code for accessing an application's bundle path:
CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
const char *pathPtr = CFStringGetCStringPtr(macPath,CFStringGetSystemEnco...
I want to go into native c++ programming after University, but it seems like languages that compile with JIT (like .Net) are overtaking c++. What does the future hold for Native code?
...
#include <iostream>
using namespace std;
class Calculator
{
public:
int number1;
int number2 ;
public:
void setCalcNumbers(int input1 , int input2 )
{
number1 = input1;
number2 = input2;
}
int addNumber()
{
...
While working on my basic vector library, I've been trying to use a nice syntax for swizzle-based printing. The problem occurs when attempting to print a swizzle of a different dimension than the vector in question. In GCC 4.0, I originally had the friend << overloaded functions (with a body, even though it duplicated code) for every dim...
Possible Duplicate:
Best ways to teach a beginner to program?
how would i know what i know is enough to build a good software? Any books that teaches you do it properly?
...
I found in some legacy code I'm dealing with this function (in C++)
Vec3d Minimum()
{
if(this->valid)
{
return minBB;
}
else
{
return NULL;
}
}
where Vec3d is a object that is basically a struct with x,y,z and some operators overloaded (code below).
AFAIK, you can't return a 0 for a user define...
#include <iostream>
using namespace std;
int main()
{
// char[20] name = "blah";
int ssn = 123456789;
int dob = 12742;
cout << ssn '\n';
cout << dob'\n';
return 0;
}
...
I have a C++ program written with Winsock that has multiple blocking sockets operating in multiple threads. They are all waiting at recvfrom(), and when I send a packet to one of them, they all get the packet. Here is how they are declared:
_sock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
if (_sock == INVALID_SOCKET) {
_error = WSAG...
At work we have a base class, let's call it IntrusiveBase, that acts something like a mixin to allow a class to be stored in a boost:intrusive_ptr. That is, it provides its subclasses with a ref count and defines intrusive_ptr_add_ref and intrusive_ptr_release overloads. The problem is that it is too easy for someone to forget that a par...