Hi!,
From past 9 years i have been using vi as my editor and have found few things which i haven't seen simple and non-stupid solutions, could any of you have better solutions.
when-ever i open a fresh file to code.. getting by default the header description.. with date,time and author name etc...basic things in place.
When-ever i ope...
Can anyone please tell my why this method won't compile?
void Statistics::readFromFile(string filename)
{
string line;
ifstream myfile (filename);
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unabl...
There are plenty of logging/trace systems for letting your program output data or strings or state as it runs. Most of these let you print arbitrary strings which you can view live or after your program runs.
I noticed an ad here on SO for Smartinspect which seems to take this to a higher level, giving stack traces for each log, fancier...
While testing some functions to convert strings between wchar_t and utf8 I met the following weird result with Visual C++ express 2008
std::wcout << L"élève" << std::endl;
prints out "ÚlÞve:" which is obviously not what is expected.
This is obviously a bug. How can that be ? How am I suppose to deal with such "feature" ?
...
Hello. I am going to start a game in about 3 weeks and I would really like the game to run at least on another platform (linux, MacOS) but my team thinks that's a lot of work. I am up for it but wanted to know what are the things I should watch out for that won't port to linux (apart from Windows specific APIs like DirectXsound)?
I've b...
The following snippet draws a gray square.
glColor3b(50, 50, 50);
glBegin(GL_QUADS);
glVertex3f(-1.0, +1.0, 0.0); // top left
glVertex3f(-1.0, -1.0, 0.0); // bottom left
glVertex3f(+1.0, -1.0, 0.0); // bottom right
glVertex3f(+1.0, +1.0, 0.0); // top right
glEnd();
In my application, behind this single square exists a colored cube.
...
There are tons of GUI libraries for C/C++, but very few of them are based on the idea that opengl is a rather multiplatform graphics library. Is there any big disadvantage on using this OpenGL for building my own minimal GUI in a portable application?
Blender is doing that, and it seems that it works well for it.
EDIT: The point of my ...
Hello,
I'm exploring a piece of software making use of Oracle API and as far as I can see often object methods expect as an argument a "OCCI context" or a "OCCI environment" values.
An example is a constructor of an Account object:
Account( oracle::occi::Environment* env );
later overloaded with
Account( void* oraCtx );
I can un...
Say I have a
struct SMyStruct
{
int MULT;
int VAL;
};
std::map<std::string, SMyStuct*> _idToMyStructMap;
Now I want to calculate total of all SMyStuct, where total is defined as MULT1 *VAL1 + MULT2 *VAL2 for each elements in the idToMyStructMap.
Seems like accumulate function is a natural choice. Please suggest. thanks
...
In case of integer overflows what is the result of (unsigned int) * (int) ? unsigned or int?
I was auditing the following function, and suddenly I came out with that question. In the below function, it is vulnerable at line 17.
1. // Create a character array and initialize it with init[]
2. // repeatedly. The size of this character ...
My cube isn't rendering as expected when I use GL_BLEND.
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
I'm also having a similar problem with drawing some semi-opaque vertices in front, which could well be related.
Related: Why do my semi-opaque vertices make background objects brighter in OpenGL?
...
I'm using a MFC CAsyncSocket to do some network communication in a multi-threaded environment. After several hours of trying to get the accepted sockets to accept incoming data I came across a page that states that for a CAsyncSocket's OnReceive function to be called the socket has to be in the context of the main GUI thread. Moving it...
Is one of these faster?
inline int ProcessByValue(int i)
{
// process i somehow
}
inline int ProcessByReference(const int& i)
{
// process i somehow
}
I know that integral types should be passed by value. However, I am concerned that the compiler might inline ProcessByValue to contain a copy. Is there a rule for this?
...
Basically I have,
typedef map<std::string, set<double> > MAP_STRING_TO_SET;
What is the best way to update (add or remove value) the set with a new value without causing the set to be copied?
The only viable solution I see is to use map<std::string, set<double>* > -- something I don't want to do.
Thanks
...
When I compile a c++ application I'm writing that makes use of hash_map, I get this warning on g++ 4.3.2:
You are using the deprecated header . To eliminate this warning, use an ANSI-standard header file or use hte -Wno-deprecated compiler flag.
9> #include <ext/hash_map>
What include replaces this? I've searched for a while on goog...
Microsoft provides a way of mounting a read-only snapshot as a volume using their vshadow program. However, it does not provide a way to unmount the snapshot (I wonder what would happen if I deleted the snapshot?). Going through the documentation on MSDN I found UnexposeSnapshot Method, and added the ability to use it in the vshadow. How...
Where, ClassA has an operator as such, that returns ClassB:
class ClassA
{
public:
ClassA();
ClassB &operator[](int index);
}
If I want to access said operator from within ClassA's constructor, as so:
ClassA::ClassA()
{
// How do I access the [] operator?
}
At the moment, as a work-around I'm just using a method called ...
Say you have
char *= "name:454";
What is the best way to parse name and the number, thus
std:string id would equal to "name";
double d would equal to 454;
STL please, no boost.
...
I'm looking for a good multiplatform library for vector graphics in C/C++. Any recommendation or thougts?
Thanks
EDIT: Thanks for all your answers!! Could anyone tell me the pros and cons of qt vs cairo, for example? Cairo got more votes, but it seems to be from 5 to 7 times slower according to some benchmarks...
...
Where is the correct place to initialize a class data member?
I have the class declaration in a header file like this:
Foo.h:
class Foo {
private:
int myInt;
};
Then I try to set a value to myInt in the corresponding .cpp file:
Foo.cpp:
int Foo::myInt = 1;
I get a compiler error for redefining myInt. What am I doing wrong???
...