wraparound_counter & operator ++() {
m_count = (m_count + 1) % upper_limit;
/*if (upper == m_count)
m_count = lower;
++m_count;*/
return *this;
}
It is my understanding that on some systems using the remainder operator trick will be faster, but on others the conditional will be faster. Is there any way to figure...
Possible Duplicate:
Why does C# execute Math.Sqrt() more slowly than VB.NET?
I'm running into an interesting problem, wherein I have code in VB.net and the exact same code in C++. I'd expect C++ to naturally run a tad faster than VB.net, but instead I'm getting the exact opposite: VB.net runs more than twice as fast as C++. Th...
I am preparing some code:
for(int a = 1; a <= 100; a++) //loop a (main loop)
{
for(int b = 1000; b <= 2000; b++) //loop b
{
if(b == 1555)
break;
}
for(int c = 2001; c <= 3000; c++) //loop c
{
.
.
.
}
}
I want to break the main loop (loop variable int a) by using a...
I have stringstream object ss1
now I would like to create another copy from this one.
I try this
std::stringstream ss2 = ss1;
or
std::stringstream ss2(ss1)
neither works
The error message is like this
std::ios::basic_ios(const std::ios &) is not accessible from bsl::basic_stringstream, bsl::allocator>::basic_stringstream(cons...
I'm confused should i learn C++ or ASM?
I'm just a hobbyist so no big deal but i need some advise.
thank you
...
I have an algorithm that can find if a point is inside a polygon.
int CGlEngineFunctions::PointInPoly(int npts, float *xp, float *yp, float x, float y)
{
int i, j, c = 0;
for (i = 0, j = npts-1; i < npts; j = i++) {
if ((((yp[i] <= y) && (y < yp[j])) ||
((yp[j] <= y) && (y < yp[i]))) &&
(x...
Is it possible to have memory for only one variable (defined in both base as well as derived class)if we create object of derived class. If can, what is the reason behind it, please provide complete explanation.
class Base
{
private:
int i;
}
class derived: public /* or private or protected (whatever fits in my question) */
Bas...
When working with a library, whether it be my own or external, there are lot of classes with forward declarations. The same classes also have includes as well depending on the situation. When I use a certain class, I need to know whether certain objects that the class uses, are forward declared or are they #include(d). The reason is I wa...
I have a C++ DLL that I have source to. It is currently logging to stdout.
I am calling methods in this dll via pinvoke from c#.
I want the c# code to be able to get the log messages, and then forward them to the c# application's own logging mechanism.
I have seen some questions/answers dealing with capturing stdout, but I cannot get ...
Addendum: I realize this post appears to take the form of a rant, but if you could correct any misunderstandings I have, clarify anything, or better yet: help me solve my problem with the iterator issue, I'd be very grateful! I'm currently using cplex 9 (I know it's not the latest, it's out of my hands).
Is it just me or could the CPLEX...
char firstName[32];
I understand that each char occupies 1 byte in memory. So does the above occupy 32 bytes of memory?
Am I missing a pointer that takes up memory too or is this just 32 bytes?
...
I was under the impression that using setjmp() and longjmp() in C++ was almost guaranteed to mess up the stack, since these functions don't perform unwinding like, say, exceptions do. This MSDN page, however, indicates that the Microsoft implementation can be told to invoke the destructors of local objects, which implies that careful use...
Hi all,
Is there any good list of techniques + descriptions for C++ newbies.
I was thinking of a list describing RAII, RVO, Lvalues...
This would be for newbies that don't currently understand those techniques or come from other languages where those are not applicable.
Something short & sweet would be preferred :-)
...
Hi All
In another community, i have people suggesting that you should 'NEVER' have attributes in your base class. Instead it should have only pure virtual functions and let the derived class take responsibility to provide definition for all these methods.
My take on it is that 'It is not a rule of thumb'. I gave following trivial examp...
I have a vector that I am iterating over. While iterating, I may append new values to the vector. It looks something like:
struct Foo
{
bool condition;
};
void AppendToVec(vector<Foo>& v)
{
...
v.push_back(...);
}
vector<Foo> vec;
...
for (vector<Foo>::size_type i = 0; i < vec.size(); ++i)
{
if (vec[i].condition) AppendT...
class arbit
{
int var;
public:
int method1();
int method1() const;
};
Why does g++ does not give warning while declaring the same function twice here ?
...
Greetings, everyone!
I have a class that receives a pointer to a "circle" (for example) and then adjusts its attributes via some "chaining" methods. Something like this:
class CCircleSetter
{
public:
explicit CCircleSetter( CCirclePtr circle ) : m_circle(circle)
{
}
CCircleSetter & Radius( int radius )
{
if (m_ci...
What is a really good Windows, C++, UI library, framework, or tool that will allow me to very simply and easily add a slick look & feel to my native C++ win32 application?
Also;
Slick means skinnable with window background images, fancy buttons, shadows, all that jazz.
This is non-MFC
Supporting Windows XP and beyond
Royalty free lice...
I assume not, but I just wanted to check - is there any way in C++ to do something like the following? Obviously when I try the below I get a scope-based error about bar.
void foo(Bar bar, int test = bar.testInt) { ... }
...
int bits = 0;
bool a = true, b = false, c = true; // 101 = 5
bits = bits | a << 2;
bits = bits | b << 1;
bits = bits | c;
cout << bits;
This is the code I am going to use to take a set of three booleans and convert it into an int for a switch statement. I have 8 cases based on the combined state of these 3 booleans. Am I doing thi...