I have enanoutered a problem with a code similar to this
void aFuncion()
{
struct entry
{
std::string field1;
int field2;
int field3;
entry(const entry& ent)
{
// copy constructor code
}
entry()
{
// default constructor ...
#include<iostream>
#include<memory>
#include<stdio>
using namespace std;
class YourClass
{
int y;
public:
YourClass(int x) {
y= x;
}
};
class MyClass
{
auto_ptr<YourClass> p;
public:
MyClass() //:p(new YourClass(10))
{
p= (auto_ptr<YourClass>)new YourClass(10);
}
MyClass( const MyClass &) : p(new Yo...
I am a newbie to c++ and please don't get mad at me for asking something
very basic. Here's my quesion:
For a class A, an integer conversion operator would look something like
operator int() //Here we don't specify any return type
{
return intValue;
}
How does the above function is able to return something when its signature say...
Hi,
I would like to create a virtual drive for windows. I'm not looking to map a drive or something like that, I'm looking to map it to my dll functions or something of that sort.
How can I get this accomplished?
I read that I would have to develop a device driver, or a shell extension?
I have a lot of experience with C++ and C#. Wher...
Hi,
I've created a method which is accept parameter by reference like following :
void Func1(QList<int> *a){
(*a) << getDataFromAnotherFunction();
//or
(*a).append(getDataFromAnotherFunction());
}
QList<int> getDataFromAnotherFunction(){
//we will do something good over here
return QList<int>
}
but the problme is when I want to us...
Google's Protocol buffer uses the C++ standard string class std::string as variable size byte array (see here) similar to Python where the string class is also used as byte array (at least until Python 3.0).
This approach seems to be good:
It allows fast assignment via assign and fast direct access via data that is not allowed with ve...
How does is differ from a usual string?
...
Assume that I have two AVL trees and that each element from the first tree is smaller then any element from the second tree. What is the most efficient way to concatenate them into one single AVL tree? I've searched everywhere but haven't found anything useful.
...
For a rules engine developed in C++, one of the core features is the value type. What I have so far is a bit like a COM-style VARIANT - each value knows its type. There are some rules for type conversion but it's a bit messy.
I wondered if there are nice drop-in value classes I could use which solve this, without requiring me to use a w...
Hi
I am having a pretty strange linking error in a project that uses automake. What I do seems pretty simple from the manual, so I really wonder what I can doing wrong ...
My project has three folders :
src/common, in which I compile a number of C++ files into a libube-common.a static lib
src/engine, in which I compile a number of...
I got trouble in creating special instance of member template function of non-template class. I have, for example, class A with template member function F:
class A
{public:
template <class T> int F (T arg) const;
....
}
and want to have a special instance of this template function F for type B:
class B;
...
template...
How to find size of an int array? eg:
int list[]={1,5,7,8,1,1,4,5,7,7,7,8,10,20};
how to the size of list?
I know for char array. We can use strlen(array) to find the size, or check with '\0' at the end of the array.
But for int array, checking '\0' seems not working.
Problem!!!!!!!!!! sizeof(array)/sizeof(array[0]) only work...
Hello!
I'm currently learning C++ and there are some (basic) things which I don't really know about and where I didn't find anything useful over different search engines.
Well as all operating systems have different "binary formats" for their executeables (Windows/Linux/Mac) - what are the differences? I mean all of them are binary bu...
I know that there are already several questions on StackOverflow about std::string versus std::wstring or similar but none of them proposed a full solution.
In order to obtain a good answer I should define the requirements:
multiplatform usage, must work on Windows, OS X and Linux
minimal effort for conversion to/from platform specif...
I've always wanted a bit more functionality in STL's string. Since subclassing STL types is a no no, mostly I've seen the recommended method of extension of these classes is just to write functions (not member functions) that take the type as the first argument.
I've never been thrilled with this solution. For one, it's not necessarily ...
I'm trying to write a unit test for my FileWatcher class.
FileWatcher derives from a Thread class and uses WaitForMultipleObjects to wait on two handles in its thread procedure:
The handle returned from FindFirstChangeNotification
A handle for an Event that lets me cancel the above wait.
So basically FileWatcher is waiting for whate...
Hi,
I have a class called Action, which is essentially a wrapper around a deque of Move objects.
Because I need to traverse the deque of Moves both forward and backwards, I have a forward iterator and a reverse_iterator as member variables of the class. The reason for this is becuase I need to know when I have gone one past the "end" ...
Instead of doing
#include "MyClass.cpp"
I would like to do
#include "MyClass.h"
I've read online that not doing so is considered bad practice.
...
Taken from http://www.ocf.berkeley.edu/~wwu/riddles/cs.shtml
It looks very compiler specific to me. Don't know where to look for?
...
I'm going to add a python console widget (into a C++ GUI) below some other controls:
Many classes are going to be exposed to the python code, including some access to GUI (maybe I'll consider PyQt).
Should I run the Python code in a separate thread?
I think it's a good approach, because GUI won't be frozen while executing long co...