Hi,
I have a number of vectors of strings each containing dates. As a simple example vector A
of size 2 might contain:
A[0] = "01-Jul-2010";
A[1] = "03-Jul-2010";
while a second vector B of size 3 might contain:
B[0] = "02-Jul-2010";
B[1] = "03-Jul-2010";
B[2] = "04-Jul-2010";
I'd like to form a vector C which contains the ...
Hi all,
Is it OK to return a reference to a local variable from a function? By local I mean that the variable would be created(on the stack i.e. without using new) within the function and its scope is within that function only. I got contradictory answers when I searched about this. 1) says that kind of usage is correct but 2) contradic...
Hi,
I have an application with several threads running. I have 2 threads that seem deadlocked when trying to allocate an std::string. Inspecting the backtrace of both threads suggest that at some point one has tried to allocate an std::string, and got a bad_alloc exception. In its catch block, another string is created in an attempt to ...
How would one go about specifying short options without their long counterparts in boost?
(",w", po::value<int>(), "Perfrom write with N frames")
generates this
-w [ -- ] arg : Perfrom write with N frames
Any way to specify short options only?
...
Hey,
I've been working on a small little application, and I've been using DirectX/3D to draw textures to the screen (all 2-dimensional elements). The API, I find, is pretty easy to use and to incorporate using OOP principles, but I can't help but feel that using DirectX on something this small is insanely over-kill.
I can't seem to fin...
I am looking to get a general understanding of the toolkit a typical C++ developer would use. What are some recommended tools and libraries for C++ development?
Please include a category with submission (e.g. IDE - Visual Studio) and single submission per recommendation.
Categories (add more if needed)
Build Tool
IDE
Unit Test Fram...
Besides all the known benefits of using auto_ptrs, what are auto_ptr "worst-practices"?
Creating STL contrainers of auto_ptrs.
auto_ptrs don't fulfill the 'CopyConstructable' requirement. See also Scott Meyer's "Effective STL", item 8.
Creating auto_ptrs of arrays
Upon destruction, auto_ptr's destructor uses 'delete' (and never 'delet...
Why this doesn't work? (For hell's sake!)
template<class T>
class A
{
typedef typename T::value_type value_type;
public:
A();
};
I'm getting following error:
Error 1 error C2825: 'T': must be a class or namespace when followed by '::
But T is a class, I've just specified that didn't I? So what's the problem?
Thanks.
...
I am trying to basically do 3 things at once here: overload the assignment operator using a template, restrict the types (using boost::enable_if), and having a specific return type.
Take this as an example:
template <class T>
std::string operator =(T t) { return "some string"; }
Now, according to boost enable_if (sec 3, bullet pt 1)...
Common pointers allows you to create pointer to pointer:
void foo(Object **o) {}
int main()
{
Object * o = new Object();
foo(&o);
}
Is there an analogous construction for shared_ptr?
void foo(std::shared_ptr <Object> *o) {}
int main()
{
std::shared_ptr <Object> o(new Object());
foo(&o);
}
...
I have MyCustomWidget in a namespace MyNameSpace
namespace MyNameSpace{
class MyCustomWidget : public QWidget{
};
}
How do I promote a QWidget to MyCustomWidget in my UI form? It doesn't seem to accept a custom namespace.
...
I am having difficulty writing my code in the way it should be written. This is my default constructor:
Address::Address() : m_city(NULL), m_street(NULL), m_buildingNumber(0), m_apartmentNumber(0)
{}
...and this is my other constructor:
Address::Address(const char* city, const char* street, const int buildingNumber,const int apartmen...
I have a Text Box that is a System::String^, I need to confirm that this only accepts 10 digits numbers and no letters, symbols, etc. How would I implement this in C++ visual studio? Do I need to convert the contents to a std::string first?
...
How do I fix this syntax error?
struct A {
template < typename T >
void f () {}
};
template < typename C, typename U >
struct B {
void g () {
U::f < C > (); // expected primary-expression before »>« token
}
};
int main () {
B<int,A> b;
b.g ();
}
...
Hi everyone.
I have the following code:
std::vector<std::string> final_output;
std::string input;
int tries = 0;
std::cin >> tries;
int counter = 0;
while(counter < tries) {
std::getline(std::cin, input);
final_output.push_back(input);
++counter;
}
Given the input:
3
Here Goes
Here Goes 2
The output is:
<blank li...
How to complete disable Drag'n Drop from a GtkEntry ?
...
Possible Duplicates:
When pass-by-pointer is preferred to pass-by-reference in C++?
Are there benefits of passing by pointer over passing by reference in C++?
How to pass objects to functions in C++?
Hi all,
I'm working to develop a large object oriented c++ application framework as part of my chemical engineering graduate...
I want to write an app in visual studio that will work in linux. It's main function will be to monitor multiple linux systems and provide health and status to the GUI... I.e disk usage, bad drives, network throughput, mysql reads/inserts, ect... Can I cross compile with visual studio 2010?
Should I even bother using visual studio? Or ...
Has a new symbol joined the C++ language specification while I was sleeping under a rock?
I just encountered the following question:
http://stackoverflow.com/questions/3621649/restrict-text-box-to-only-accept-10-digit-number-c
Which suggests that the '^' symbol is somehow part of C++ (not in the legacy meaning of a bitwise-XOR)
Is th...
I add the following preprocessor code in header files all the time.
#ifdef _HELLO_H_
#define _HELLO_H_
#endif
Is there a way to do this automatically (I mean, when I load the header file for the first time, the emacs just adds the code), or manually (I mean, I have some M-x SOMETHING)?
If none exists, how can I program the elisp co...