I've been trying to follow the principles of Dependency Injection, but after reading this article, I know I'm doing something wrong.
Here's my situation: My application receives different types of physical mail. All the incoming mail passes through my MailFunnel object.
While it's running, MailFunnel receives different types of messag...
I have a class that is wrapped with swig, and registered with lua. I can create an instance of this class in a lua script, and it all works fine.
But say I have an instance of a class made in my c++ code with a call to new X, and I have la lua_state L with a function in it that I want to call, which accepts one argument, an instance of ...
Dear all,
I have the following C++ code that tried to generate
a random number. The idea is we given some rate "x" and number of runs;
we hope it would generate the number as many as (x * number of runs times).
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <time.h>
using names...
I need books that truely explian sockets in windows in C++ ive been looking at tutorials but they dont tell what anything means they dont go into great detail so i need come books on Winsock in C++ for windows
...
I'm trying to work on a kind of code generator to help unit-testing an legacy C/C++ blended project. I don't find any kind of independent tool can generate stub code from declaration. So I decide to build one, it shouldn't be that hard.
Please, anybody can point me a standard grammar link, better described by yacc language.
Hope I'm n...
I have the following snippet:
string base= tag1[j];
That gives the invalid conversion error.
What's wrong with my code below? How can I overcome it.
Full code is here:
#include <iostream>
#include <vector>
#include <fstream>
#include <sstream>
#include <time.h>
using namespace std;
int main ( int arg_count, char *arg_vec[] ) {
...
Is there some way to delay defining the size of an array until a class method or constructor?
What I'm thinking of might look something like this, which (of course) doesn't work:
class Test
{
private:
int _array[][];
public:
Test::Test(int width, int height);
};
Test::Test(int width, int height)
{
_array[width][he...
This seems inconsistent. Why do we use &Example::func instead of Example::func? is there a use for Example::func or &exampleFunction? it doesnt seem like we can make a reference to a function so that rules out Example::func. and i cant think of a way to use &exampleFunction since exampleFunction already returns a pointer.
#include <iost...
I tried to make character by character comparison under string type,
with the following code:
vector <int> getQuality(string seedTag, vector <string> &MuTag) {
vector <int> Quals;
for (unsigned i = 0; i<MuTag.size(); i++) {
Quals.push_back(-40);
cout << MuTag[i] << " " << seedTag[i] << endl;
if...
is there any tristate type in c++ stl?
...
When you know that your software (not a driver, not part of the os, just an application) will run mostly in a virtualized environment are there strategies to optimize your code and/or compiler settings? Or any guides for what you should and shouldn't do?
This is not about a 0.0x% performance gain but maybe, just maybe there are simple t...
Dear all,
The following codes try to generate random strings over K runs.
But we want the newly generated strings to be totally different
with its reference string.
For that I tried to use "continue" to restart the random
string generation process. However it doesn't seem to work.
What's wrong with my approach below?
#include <iostre...
Hello. I’ve got the following code:
#include <iostream>
using namespace std;
int main()
{
char* a = "foo";
char* b = "bar";
a = b;
cout << a << ", " << b << endl;
return 0;
}
This compiles and works, ie. prints bar, bar. Now I would like to demonstrate that what goes on here is not copying a string. I would like to...
I need to write a templated function replace_all in C++ which will take a string, wstring, glibmm::ustring etc. and replace all occurrences of search in subject with replace.
replace_all.cc
template < class T >
T replace_all(
T const &search,
T const &replace,
T const &subject
) {
T result;
type...
I am developing a graphics application using Qt 4.5 and am putting images in the QPixmapCache, I wanted to optimise this so that if a user inserts an image which is already in the cache it will use that.
Right now each image has a unique id which helps optimises itself on paint events. However I realise that if I could calculate a hash...
What order should headers be declared in a header / cpp file? Obviously those that are required by subsequent headers should be earlier and class specific headers should be in cpp scope not header scope, but is there a set order convention / best practice?
...
I'm getting several of the following warnings in VS2005 on an old project after moving from my old XP to a new vista PC:
UnitTest++.vsnet2005.lib(TestRunner.obj) : warning LNK4099: PDB 'vc80.pdb' was not found with 'c:\projects\blah.lib' or at 'c:\projects\blah\debug\vc80.pdb'; linking object as if no debug info
I know that this wa...
I have to read business rules stored in XML file (I am using VC++/MFC/MSXML). XML consists of rules. Each rule has a set of conditions and actions. What would be an elegant OOP design for such system? What design patterns would you use if you where a designer of such system?
update:
Rules are put in sequence and executed one buy one if ...
Hi,
I am currently porting a project with a few hundred code files and dependencies onto several third-party libraries to Mac Os. I've finally gotten to the point where the program compiles without warnings or errors, but it does not seem to execute my own main function.
Instead it seems to execute some other main function which seems...
Hi,
I am looking for a version of the gcc (C++) compiler targeting the ARM uP and WindowsCE operating system. Thus far I have only been able to locate compilers which either target the ARM uP but produce ELF executables (GNUARM etc) or they do target windows CE but have not been updated since 2003. I believe the exact name of the compil...