So here's my question in the function declaration there is an argument and it is already initialized to a certain value. What are the procedures to call this function and use that default value, or is it just a way to document code, telling other programmers what you expect them to use as a value for the parameter? Thank you.
enum File...
Consider the following minimal example:
#include <iostream>
using namespace std;
class myostream : public ostream {
public:
myostream(ostream const &other) :
ostream(other.rdbuf())
{ }
};
int main() {
cout << "hello world" << endl;
myostream s(cout);
s << "hello world" << endl;
myostr...
I suspect some ASSERTION code is having side effects. I'd like to switch off ASSERT without making any other changes to how my code is compiled. I'm using MSVS2008. Switching from debug to release won't do as that will alter how memory is initialised.
...
I'm trying to use a pre-build event in Visual Studio (VS 2005 to be specific) to run a Python script which will automatically generate a .cpp file. The trouble I'm running into is that the compiler doesn't seem to know that this file is dirty and needs to be rebuilt until after the build has finished, which means that I need to build th...
Hey all, I'm in the process of debugging a C++ app on mac os 10.5. Occasionally, I'll do something bad and cause a segfault or an otherwise illegal operation. This results in the app hanging for a while, and eventually a system dialog notifying me of the crash. The wait time between the "hang" and the dialog is significant; a few minutes...
Lets say I have a ushort value that I would like to set bits 1 to 4 inclusive (assuming 0 is the LSB and 15 is the MSB).
In C++ you could define a struct that mapped out specific bits:
struct KibblesNBits
{
unsigned short int TheStart: 1;
unsigned short int TheMeat: 4;
unsigned short int TheRest: 11;
}
Then you could assign...
I need a way to have a single static variable for all kinds of types of my template class
template <class T> class Foo { static Bar foobar;};
Well, the line above will generate a Bar object named foobar for every type T, but this is not what i want, i basically want a way to declare a variable of type Bar, so every object of type F...
I'm currently developing various console games in Windows that won't really work using regular input via cin.
How can I (In a simple way using only standard windows libraries available in MSVC):
Make the program wait for a (specific?) key press and return the key ID (It would have to work for all keys including the arrow keys)
During ...
Possible Duplicates:
Why this is a pointer and not a reference?
SAFE Pointer to a pointer (well reference to a reference) in C#
The this keyword in C++ gets a pointer to the object I currently am.
My question is why is the type of this a pointer type and not a reference type.
Are there any conditions under which the this ke...
I've set up my target toolchain (ARM), I can compile my projects, and launch them on the remote hardware (an OMAP3 based board).
I have set up project properties for remote debugging for my target.
But when I launch the debug process, it seems to launch "system's default gdb" instead of the one configured in Settings\Compiler and Debug...
I was happily working in C++, until compilation time arrived.
I've got several classes inside some namespace (let's call it N); two of these classes correspond to one base class, and other derived from it. Each class has its own pair of .hpp and .cpp files; I think it'd look like:
namespace N{
class Base{
};
class Derived...
I was reading the explanation under this item in the Google C++ style guide and it got me thinking; are there any tools that work like VS's "Find all references" tool but for built in ops and the like? For example say I want to find all places where the native "+" operator is used on a pointer (or maybe just a pointer to an object) and a...
Really simple question about C++ constness.
So I was reading this post, then I tried out this code:
int some_num = 5;
const int* some_num_ptr = &some_num;
How come the compiler doesn't give an error or at least a warning?
The way I read the statement above, it says:
Create a pointer that points to a constant integer
But some_num ...
i noticed that the boost library uses header files of (.hpp).
I am curious since most source files i see use normal .h header files.
Could there be any special instances which warrant use of .hpp instead of .h
Thanks
...
In the printMessage if you access the vector of a constant class using the index it works fine, but not with the the iterator (*itr). If the iterator is declared as constant_iterator then it works fine.
Why?
In both cases I am reading the data and not modifying the vector. Can someone shed some light?
#include <iostream>
#inclu...
I never really had a necessity for a global variable in a template (and actually I don't support a design like this very much) but this topic got me curious.
Even though answered, it inspired me trying a different approach. Instead of using inheritance, I came up with this:
class Bar {};
class {
private:
Bar bar;
template <cla...
How do I get the number of bits in type char?
I know about CHAR_BIT from climits. This is described as »The macro yields the maximum value for the number of bits used to represent an object of type char.« at Dikumware's C Reference. I understand that means the number of bits in a char, doesn't it?
Can I get the same result with std::nu...
I've got a strange problem here. Assume that I have a class with some virtual methods. Under a certain circumstances an instance of this class should call one of those methods. Most of the time no problems occur on that stage, but sometimes it turns out that virtual method cannot be called, because the pointer to that method is NULL (as ...
A word is grouped if, for each letter in the word, all occurrences of that letter form exactly one consecutive sequence. In other words, no two equal letters are separated by one or more letters that are different.
Given a vector<string> return the number of grouped words.
For example :
{"ab", "aa", "aca", "ba", "bb"}
return 4.
He...
I'm looking for vocoding capabilities from C++.
I can't seem to find a lib/api.
Recommendations?
...