The following C++ code does nothing (using GCC 4.4.3) - it does not print the text:
struct MyStruct { MyStruct() { cout << "Hello" << endl; } };
void foo() {
MyStruct ();
}
I think this is not so obvious... Let alone the danger of forgetting to give a variable name. Is there a compiler option/warning to forbid compilation of such c...
I'm learning OpenMP. To do so, I'm trying to make an existing code parallel. But I seems to get an worse time when using OpenMP than when I don't.
My inner loop:
#pragma omp parallel for
for(unsigned long j = 0; j < c_numberOfElements; ++j)
{
//int th_id = omp_get_thread_num();
//printf("thread %d, j = %d\n"...
Can anybody tell me about the virtual table concept?
...
hi....
difference between widening and narrowing in c++?
what is mean by casting and what is types of casting?
...
This is a snippet of code I use:
void Move::AddToMovesList(Location* &list, int row, int col) {
// If the list is empty, create the first item
if (list == NULL)
list = new Location(row, col);
// List exists, so append
else
list->Add(row, col);
}
If list is NULL, a new Location should be created and the ...
So I'm trying to read this file. Everything looks like it should work, but during runtime the program times out and stops working, and I have to close it. What is going on? I suspect that the oef() test is never returning true and it keeps looking for more in the file. I have no dragging empty lines in the text file. I've tried debugging...
I'm implementing my own graph library in linux (Fedora 10 and CentOS 5) with gcc 4.3.2 and using STL containers then I found some problems with memory. When I build my graph, I use a lot of memory enough to be view in top or another memory usage tool. I'm sure that I'm deallocating that memory (I reviewed the code again and again and I u...
Hi all.
How to determine elements count in boost.preprocessor tuple`s ?
Thanks.
...
What am I doing wrong?
#include "stdafx.h"
#include <iostream>
#include <string>
using std::cout;
using std::string;
template<int v>
struct Int2Type
{
enum {value = v};
};
template<bool condition,class Left, class Right>
struct Result;
template<class Left, class Right>
struct Result<true,Left,Right>
{
typedef Left value;
}...
is there a simple way to make Visual Studio 2008 use 8.0 CRT libraries in my c++ project? I really do not want to install Visual Studio 2005 just to do this. Thanks
...
Hi,
I wrote a small sparse matrix class with the member:
std::map<int,std::map<int,double> > sm;
The method below is the function i use to access the elements of a matrix, if not possible through an iterator:
double matrix::operator()(int r,int c) const
{
std::map<int,std::map<int,double> >::const_iterator i = sm.find(r);
if(...
Hello! I've received this message with Netbeans. I use Cygwin and because of university I use an older version. Before installing this older version Netbeans compiled correctly with a recent version of Cygwin. I can compile with Dev-Cpp. Anyone knows how to fix this error?
1 [main] make 4064 fork_copy: linked dll data/bss pass 0 f...
Given that the following snippet doesn't compile:
std::stringstream ss;
ss << std::wstring(L"abc");
I didn't think this one would, either:
std::stringstream ss;
ss << L"abc";
But it does (on VC++ at least). I'm guessing this is due to the following ostream::operator<< overload:
ostream& operator<< (const void* val );
Does this h...
Hi,
I would like to ask how can I stop a process programatically using C++?
Thanks.
...
I'm documenting some code in C++ right now, and one of the methods I intend to write will sort an array. It won't create a new array, though, it will sort the elements of the given array in place. I want to include a remark along the lines of, "if the original ordering was important to you, then don't use this method!" But I would rather...
I would like to install Boost library without the need of Visual Studio compiler, preferably by downloading the pre-compiled binaries. We are working on a cross-platform C++ project in Eclipse, so VS is out of option.
About a year ago, I found an installer, but it does not longer exists.
The best match I have found so far is from:
http:...
I wrote an application using wxWidgets that uses wxList. I am having some random crahses (segfault) in the destructors that collect the list data. I could not find a definite way of removing items from the list (Erase() VS DeleteNode()). Even iterating over the items has two flavours (list->GetFirst() VS list->begin()).
Below is a test ...
when i debug the following code, the string copy copies fine but as soon as the loop exits the
char**(parent_var_names) is pointing NULL/0xfdfdfddf
I am puzzled?!
parent_var_names=(const char**)calloc(net->nodes[x]->num_parents,sizeof(const char*));
for(int i(1);i<net->nodes[x]->num_parents;++i)
{
parent_var_names[i]=(const char*)mal...
In C++ I have an array of pointers to Player objects and want to fill it with Fickle objects where Fickle is a class that is derived from Player. This is because I want a general Player array that I can fill with different objects from different classes that all are derived from the Player class.
How can I do this?
I create an array o...
Hi All,
I'm trying to implement a function that allows me to make a call like this
// veca is a vector of tuples in my case
columnViewOfTuple<0>(veca);
I implemented such function as follows
template<int N>
struct myfunction {
template<typename T, typename R>
std::vector<R> operator() (T& container)
{
std::vector<...