What is the function of the following C++ template class? I'm after line by line annotations:
template<class T> string toString(const T& t, bool *ok = NULL) {
ostringstream stream;
stream << t;
if(ok != NULL) *ok = stream.fail() == false;
return stream.str();
}
Is it like Java's toString() method?
...
CUnknown* (*)( LPUNKNOWN pUnk, HRESULT* phr );
Seems I've always been in trouble reading such complicated pointers..
How do you read it? what if the expression even longer?
...
Hey guys,
I'm looking to get a career started in game programming, (like every other recent college graduate with a CS degree) and I see a lot of places require C/C++ fluency. I'm very comfortable with C, but my C++ is rusty at best and I've never used either for any kind of game programming.
Can anyone recommend some good reading or ...
I am using PC-Lint (great tool for static code analysis - see http://www.gimpel.com/)
For the following chunk of code:
class ASD {
protected:
template<int N>
void foo();
};
template<>
inline void ASD::foo<1>() {}
template<int N>
inline void ASD::foo() {}
PC-lint gives me a warning:
inline void ASD::foo<1>() {}
m...
I am trying to understand how are file descriptors related to sockets. As per my understanding, you listen on a particular file descriptor, once a connection comes in , you accept it , which returns you another file descriptor ( 2 in all ) and you use this 2nd descriptor to send/recv data.
The strange behaviour i am observing is that a...
I have an array that is like this:
unsigned char array[] = {'\xc0', '\x3f', '\x0e', '\x54', '\xe5', '\x20'};
unsigned char array2[6];
When I use memcpy:
memcpy(array2, array, 6);
And print both of them:
printf("%x %x %x %x %x %x", array[0], // ... etc
printf("%x %x %x %x %x %x", array2[0], // ... etc
one prints like:
c0 3f e 5...
Hello,
At my company we're still using Visual Studio 2005, but are peeking at Visual Studio 2010 in the hope that it will speed up some parts of our development cycle. At the moment we're most interested in the performance of the C++ linker of Visual Studio 2010. When building our application, we're looking at link times between 40 seco...
I guess I'm a very experienced .Net developer for more than 5 years. I also have experiences on java and even written applications with Borland C++ Builder and also done iPhone apps. Now, I am in a situation that I need to rewrite a .net cf app for a wince device which doesn't have .net framework. So, basically, I need to learn Visual C+...
Hello,
At my company we really like for our development tools to be able to be used from perforce, without having been installed. For a lot of tools (perforce, gcc compiler, snc compiler, even maya) this works after some tweaking, but for Visual Studio 2005 we could not get it to work. As far as we could see, the problem was caused by m...
I've just spent a whole day trying to find a way to enable gdb debugging from QtCreater or Eclipse. I learned that there are basically two approaches to launch the target application:
using ssh (ssh host gdb)
using gdbserver
I was able to use both approaches to launch gdb remotely and start the application. However, GDB never reponds...
Say I have the following code:
struct date {
int day;
int month;
int year;
};
class mydateclass {
public:
int day;
int month;
int year;
};
mydateclass date;
date.day;
Which date variable is being referred to? The date instance named mydateclass, or the date struct?
...
Background:
I'm using Google's protobuf, and I would like to read/write several gigabytes of protobuf marshalled data to a file using C++. As it's recommended to keep the size of each protobuf object under 1MB, I figured a binary stream (illustrated below) written to a file would work. Each offset contains the number of bytes to the nex...
When should one use a semaphore and when should one use a conditional variable (CondVar) ?
...
Is it possible to update only a part of a file in c++ ?
Example:
Old File A: 'A''A''A''B''B''C''C''C'
New File A: 'A''A''A''X''X''C''C''C'
as the real files are not as tiny like these examples, and I do know exactly what has changed ( offset and writeLenght for changed content ) it would be great to be able to open a file, set the ...
Hello all,
I am very new to the C++ STL, so this may be trivial. I have a ostream variable with some text in it.
ostream* pout;
(*pout) << "Some Text";
Is there a way to extract the stream and store it in a string of type char*?
...
Is there any way to access the file descriptor of a file opened in c++? So ...
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream inputFile( "file.txt",ios::in );
cout << inputFile.fileDesc << endl;//made up call
return 0;
}
The question is, does something like fileDesc exist for...
My main() crashes below when add(4) is called.
As I understand int* add, it should return a pointer to integer. Then, I should be able in main to say:
int * a = add(3);
to return a pointer to int.
Please explain what I'm doing wrong.
#include <cstdlib>
#include <iostream>
using namespace std;
int* add (int a) {
int * c, d;
...
Hey guys,
I have a struct I have written which is supposed to represent an entire UDP packet, with the ethernet header and all. Here it is:
#pragma pack(1)
struct UDPPacket {
// an array to hold the destination mac address of the packet
unsigned char dstmac[6];
// an array to hold the source mac address of the packet
un...
I was told that these types, that are visible in there own unique translation unit, were in violation of the One Definition Rule. Can someone explain this?
//File1.cpp
#include "StdAfx.h"
static struct S { int Value() { return 1; } } s1;
int GetValue1() { return s1.Value(); }
//File2.cpp
#include "StdAfx.h"
static struct S { int Value(...
I'm developing Qt application for Mac OS X.
Problem is when I create QToolButton it apears with some outline.
http://i.imgur.com/vqtP9.png
I use next stylesheet
QToolButton {
border: 1px solid #575757;
border-radius: 4px;
}
How to remove the outline?
ANSWER:
I didn't mentioned that I'm adding this item to statusBar().
...