Hi when i try to run c++ code I am getting the following error
mainwindow.h
class MainWindow
{
public:
MainWindow();
~MainWindow();
method();
};
and
mainwindow.cpp
#include mainwindow.h
MainWindow::MainWindow(){
//some code here
}
MainWindow::~MainWindow(){
//some code here
}
MainWindow::method(){
//som...
I have a warning in my C++ code, regarding the use of FLT_MAX. The code is (very simply):
const float a_lot = FLT_MAX;
The generated warning is:
warning C4756: overflow in constant arithmetic
And it doesn't help if I change the code to:
const float a_lot = std::numeric_limits<float>::max();
I'm using Microsoft Visual Studio 2...
I am trying to convert int to string and after that merge string with the new string from int.
Like it is done in this example a_http://www.cplusplus.com/forum/beginner/1057/
Any hints what did i mess up?
http://img571.imageshack.us/img571/6027/001kb.jpg
...
Pretty simple question .. Are there any predefined functions in Qt which save a QImage object to a JPG/PNG/BMP file ?
...
Is it possible to declare a pointer to private data member of a class? If so, how do you do it?
...
I read an article on virtual table in Wikipedia.
class B1
{
public:
void f0() {}
virtual void f1() {}
int int_in_b1;
};
class B2
{
public:
virtual void f2() {}
int int_in_b2;
};
used to derive the following class:
class D : public B1, public B2
{
public:
void d() {}
void f2() {} // override B2::f2()
int int_in_d;
};...
I'm writing a small program to calculate a physics problem but I'm having problems erasing elements from a 2D array. I'm compiling with XCode (so GDB).
The problem always comes in the walker.erase(walker.begin()+loacationInArray) part (in the void diffuseWalkers function), and always after a different number of function calls. So somet...
In C++ I'm using boost::shared_ptr and boost::weak_ptr to automatically delete objects that are no longer needed. I know these work with reference counting.
In Java, memory is managed by a garbage collector, which consideres the built-in object references as strong, WeakReference as weak and SoftReference as something in between (may be...
hello, everybody, I've just finished my course Introduction to Systems Programming, the last part of it was C++, I learned a lot of stuff, but all I used to write was some console programs, I want to begin to write something new on c++ (something with graphic windows or maybe small game) to improve my knowledge, from which point can I s...
Hi!
I'm reading something about overload resolution and I found something that bothers me...In the following code:
int const& MaxValue(int const& a, int const& b)
{
return a > b ? a : b;
}
void SomeFunction()
{
short aShort1 = 3;
short aShort2 = 1;
int const & r2 = MaxValue(aShort1, aShort2); // integral promotion
...
I thought the C/C++ vs C#/Java performance question was well trodden, meaning that I'd read enough evidence to suggest that the VM languages are not necessarily any slower than the "close-to-silicon" languages. Mostly because the JIT compiler can do optimizations that the statically compiled languages cannot.
However, I recently receive...
I am using the CURL c++ api to get quotes from Yahoo's financial API. The curl api and my code seem to be working fine, however I am getting a "301" redirect message when I tell CURL to visit the url I want. How can I get CURL to follow through to the 301 redirect and get the data I want?
Here is the URL I am using:
http://download.f...
Hi guys .. Well I'm using the following code to get the filename for a file that needs to be stored ..
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"/home/user/MyDocs/",tr("JPG files (*.jpg);;BMP files (*.bmp);;PNG files (*.png)"));
I'm providing the user with a number of options regarding the file format in w...
hello
how can i create an istream from a buffer unsigned char* or vector.
basically i want :
void Func(vector<unsigned char> data)
{
someSortOfIstream x (data);
x >> something;
}
using boost too....
...
I am trying to install CLang from the source but getting unknown errors. The error is
make[2]: Leaving directory `/home/ram/Desktop/llvm/tools/llvmc'
make[2]: Entering directory `/home/ram/Desktop/llvm/tools/clang'
make[3]: Entering directory `/home/ram/Desktop/llvm/tools/clang/include'
make[4]: Entering directory `/home/ram/Desktop/llv...
Hi
How can I force a template parameter T to be a subclass of a specific class Baseclass?
Something like this:
template <class T : Baseclass> void function(){
T *object = new T();
}
Thanks in advance.
...
Hello,
I currently have a small (I'm a complete beginner) project in VTK where I've used different vtkParametricFunctionSource objects and arranged them spatially. Now what I want to do is find a way to output all that data I'm currently rendering into a .stl file.
I don't know how I'd manage to convert my implicit parametric functio...
I was reading the Wikipedia article on virtual inheritance. I followed the whole article but I could not really follow the last paragraph
This is implemented by providing
Mammal and WingedAnimal with a vtable
pointer (or "vpointer") since, e.g.,
the memory offset between the
beginning of a Mammal and of its
Animal part is...
So I've been trying to get a REG_SZ value out of the registry and store it as a char*. After looking around the internet this is what I came up with. The problem is that the value I get is not what is stored in the registry, I get a bunch of random garbage. How would I correctly get the value?
HKEY hKey;
char value[256];
// Open the key...
In definition of pair class in c++ there are two typedefs. what are they for? there are no use of them in the code!
template <class T1, class T2> struct pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair() : first(T1()), second(T2()) {}
pair(const T1& x, const T2& y) : first(x), second(y) {}
t...