I've found this odd case of some code (below) doesn't compile under Visual Studio 2008 and produces an "error C2872: 'Ambiguity' : ambiguous symbol" on line 12.
Removing the using namespace RequiredNamespace on the last line fixes the error, but I'd expect that putting using namespace at the end of a file should have no effect. It also...
Is there a quick way to determine the version of the Boost C++ libraries on a system?
...
I want to serialize a string (Korean string) containing double byte characters. Do I need to do something special?
I am able to serialize char * strings by escaping special characters like \n,\b,\f,\t etc.
I am using C++ on Windows without any libraries.
...
I use Boost.Serialization to serialize a std::map. The code looks like this
void Dictionary::serialize(std::string & buffer)
{
try {
std::stringstream ss;
boost::archive::binary_oarchive archive(ss);
archive << dict_;
buffer = ss.str();
} catch (const std::exception & ex) {
throw DictionaryException(ex.what());
...
Hi, I need to store strings in key value format. So am using Map like below.
#include<map>
using namespace std;
int main()
{
map<string, string> m;
string s1 = "1";
string v1 = "A";
m.insert(pair<string, string>(s1, v1)); //Error
}
Am getting below error at insert line
error C2784: 'bool std::operator <(const std:...
I know this will sound weird but i need my app to run fast and it does a lot of new and delete. All function calls new and passes the ptr back expect for the ones pushing a pointer to a list or deque.
At the end of the main loop the program goes across all of that memory and deletes it (unless i forgot to delete it). I am not exaggerati...
In C++ specifically, what are the semantic differences between for example:
static const int x = 0 ;
and
const int x = 0 ;
for both static as a linkage and a storage class specifier (i.e. inside and outside a function).
...
Hi,
I'm trying to add several images using opencv. I think that my source code should be correct and it compiles without any problems. But when I start the program an error occurs in the for-loop. The problem is that I don't understand why this is happening.
#include <iostream>
#include <sys/types.h>
#include <dirent.h>
...
After spending hours searching for a simple way to to add an image to an openGL application written in C++, i failed, miserably. It is also apparent that many others have too.
I am fairly new to OpenGL, I have written my own win32 app with OpenGL using DevIL and you guessed it, i failed.
The only way i could get DevIL to work was using ...
If the value of node in the xml is null, when we print the xml node, the node has no start tag, but only the end tag. For example:
xml_document<char> doc;
doc.append_node(doc.allocate_node(rapidxml::node_element, "mynode", ""));
ofstream ofs("test.xml");
ofs<<doc;
the content of test.xml is:
</mynode>
the expected content of test.x...
I want to overload << operator in a Line class so I can print an object using cout like this:
cout << myLineObject << endl;
but this is not working:
class Line{
public:
float m;
float b;
string operator << (Line &line){return ("y = " + line.m + "x + " + line.b);};
};
I get:
Invalid operands of types 'const char [5]' an...
Hello
I need to write a DirectShow capture filter that wraps the "real"
video device (fitler) and deinterlaces the captured video. From the
interface perspective, this has to be a separate video device
available in enumerator and when choosen, it connects to a real video
device and inserts a transform filter (deinterlace) between v...
Hi,
This is a general design question from C++ perspective. I have a container class which contains objects of 2 other classes.
From container class we can call methods of the contained class object "as we have handle to the contained class object" e.g. objContainedClass1->SomeMthod();
But I want to know how would the contained class ...
I need to escape all special characters and replace national characters and get "plain text" for a tablename.
string getTableName(string name)
My string could be "šárka65_%&." and I want to get string I can use in my database as a tablename.
...
I find that in the following code snippet
const int i = 2;
const int* ptr1= &i;
int* ptr2 = (int*)ptr1;
*ptr2 =3;
i's value changes to 3. What I could like to know is why is this allowed. What are the situations in which this could become helpful?
...
Both functions GetTotalDays and GetDays of COleDateTimeSpan class returns number of days contained in object:
GetTotalDays: http://msdn.microsoft.com/en-us/library/d22h87z4(v=VS.80).aspx
This date/time-span value expressed in days
GetDays: http://msdn.microsoft.com/en-us/library/ze8kz4yw(v=VS.80).aspx
The day portion of this d...
Hi,
The following code doesn't work:
class String{
public:
char* str;
int* counter;
String(){
str = NULL;
counter = new int;
*counter = 1;
};
String(const char* str1){
String();
str = new char[strlen(str1)+1];
strcpy(str, str1);
};
};
I've changed the call to...
I have this member function in my Folder class:
string _recFullPath() {
list<Folder*> folders;
list<Folder*>::iterator it = folders.begin();
folders.push_front(this);
it = folders.begin();
while((*it)->hasParent()) {
folders.push_front((*it)->parent());
it = folders.begin();
}
folders.push_back(this);
for(it = folders.begin(...
I am kind of getting bogged down by the concept of memory management (all my previous programming languages doesn't need me to manage the memory). I'm not sure if creating a variable will consume memory if I don't destroy it later.
#include <math.h>
#include <iostream>
using namespace std;
double sumInfiniteSeries(double u1, double r){...
I am working in a project using openframeworks and I've been having some problems lately when writing XMLs. I've traced down the problem to a sprintf:
It seems that under certain conditions an sprintf call may write commas instead of dots on float numbers (e.g. "2,56" instead of "2.56"). In my locale the floating numbers are represented...