I am migrating from Visual Studio 6 to Visual Studio 2008 and I have a function of a component I am using named SetDefaultPrinter.
Unfortunately there is a windows library function now, SetDefaultPrinter, with the same name. And the macro associated with it is getting in the way of me using my function.
This is my workaround I have to ...
How do I make a template specialization that takes 2 parameters versus the normal 1?
I was building a pointer class and now I thought about extending to make an array but if I try something like this:
template<class T,int s> class pointer{};
template<class T> class pointer{};
class mama{};
int main(){
pointer<mama> m;
}
It gives ...
I created an application, with the mingw compiler in a WinXP system. It worked fine. I then tried to run it in an older WinXP box(this has been in the shelf for some 6 months). The application terminated with an exception --'The application could not initialize (0xc0150002)'.
Running depends.exe on the app shows two unavailable dlls(ie...
As the title asks.
My understanding of a deque was that it allocated "blocks". I don't see how allocating more space invalidates iterators, and if anything, one would think that a deque's iterators would have more guarantees than a vector's, not less.
...
When I compile a program in C++ (that is too large to simply cut abd paste here), I get this error:
c:\program files\microsoft visual studio 9.0\vc\include\fstream(934) : error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'
What does this error mean, wh...
Let's say I have 3 classes. I expect sizeof() each class to be exactly the same--say 512 bytes.
How can I use something like BOOST_STATIC_ASSERT to apply to all of them such that
I only need to use BOOST_STATIC_ASSERT in a single place (DRY principle)
Evaluated once at compile-time and not run-time
Note: we can use whatever C++ tech...
This warning is triggered multiple times in my code by the same declaration, which reads :
// Spreadsheet structure
typedef struct SPREADSHEET
{
int ID; // ID of the spreadsheet
UINT nLines; // Number of lines
void CopyFrom(const SPREADSHEET* src)
{
ID = src->ID;
...
I'm trying to detect memory leaks by globally overloading new and delete for debug builds and maintaining a list of allocated blocks. This works, but incorrectly reports leaks for some static objects. For example a static std::vector itself is not allocated using new and delete but its internal buffers are. Since my detection code runs b...
I'm using swig to wrap a class from a C++ library with python. It works overall, but there is an exception that is thrown from within the library and I can't seem to catch it in the swig interface, so it just crashes the python application!
The class PyMonitor.cc describes the swig interface to the desired class, Monitor.
Monitor's cons...
I'm trying to build the following block of code in a 1-file .cpp file:
#include <iostream>
#include <algorithm>
using namespace std;
class test
{
public:
int a[10];
int index;
test();
~test();
bool equals(int p);
void search();
};
test::test()
{
int temp[10] = {4, 9, 5, 6, 9, 10, 9, 255, 60, 0};
me...
EDIT: Apparently, the problem is in the read function: I checked the data in a hex editer
02 00 00 00 01 00 00 00 00 00 00 00
So the zero is being stored as zero, just not read as zero.
Because when I use my normal store-in-bin file function:
int a = 0;
file.write(reinterpret_cast<char*>(&a), sizeof(a));
It stores 0 as the char ve...
i'm not sure why i cant get diff values for my variables here, help!
int main()
{
srand(time(NULL));
srand48(time(NULL));
Packet* firstPacket = new Packet();
firstPacket->packetSize = randSize();
firstPacket->dest = randDest();
firstPacket->arrivalTime = myExp(lamb);
Host[firstPacket->dest].Frame.push_back(f...
Basically what I want to do is, depending on the some variable, to cast a void pointer into a different datatype. For example (the 'cast' variable is just something in order to get my point across):
void* ptr = some data;
int temp = some data;
int i = 0;
...
if(temp == 32) cast = (uint32*)
else if(temp == 16) cast = (uint16*)
el...
I'm trying to learn c++ and I really want to do a lot of coding but I'm not sure what I can code.. Tbh, book exercises are not very interesting to me (usually because they're just too short). I like to code OS related stuff like I/O stuff..
I'm thinking of looking at linux and try mimicking some of the tools there.. is that a good idea?...
I am using ASSERTE macro to check for pre-conditions. According to its definition it is using ASSERT_BASE, which in turn calls _CrtDbgReportW to print out the message. Where does _CrtDbgReportW output goes to?
I would assume that if the application is started from debugger, it would go to debugger window. Where would the messages go if ...
I'm bit confused regarding iterator invalidation in deque.
(In the context of this question)
Following is the excerpts from -- The C++ Standard Library: A Tutorial and Reference,
By Nicolai M. Josuttis
Any insertion or deletion of elements
other than at the beginning or end
invalidates all pointers, references,
and iterator...
I've been reading a lot about Unit tests and Test Driven developemnt.
Recently, I also read java unit test code.
I however, prefer to develop in Qt. So I googled up "unit testing in c++" and found a host of information about various unit testing frameworks available for C++.
However, I could not find a reliable comparison of the the v...
I want to fit strings into a specific width. Example, "Hello world" -> "...world", "Hello...", "He...rld". Do you know where I can find code for that? It's a neat trick, very useful for representing information, and I'd like to add it in my applications (of course).
Edit: Sorry, I forgot to mention the Font part. Not just for fixed widt...
Hi
i have created some application in managed c++.when i try to instantiates it shows error as
cannot convert from obj to *obj. when i instantiates as pointer obj it shows no error.
so. is there any way to access such class without creating pointer object
...
I work with a guy who prefers to name his member variables using the mCamelCase convention, for example: mSomeVar or mSomeOtherVar. I can't stand this format. I prefer the m_camelCase convetion, for example: m_someVar or m_someOtherVar. We drive each other mad looking at each other's code.
Now we've added a new guy to the team and he...