I'm trying to typedef either an unordered_map or std::map depending whether there are TR1 libraries available. But I don't want to specify the template parameters. From what i've read so far, typedef'ing templates without arguments is not possible until official c++0x standard is available. So does anyone know an elegant workaround for t...
How do I read data from a file if my file is like this with comma separated values
1, 2, 3, 4, 5\n
6, 7, 8, 9, 10\n
\n
and after reading the file, I want to write the data back into other file as same format above.
I can get total number of lines, using
string line;
while(!file.eof()){
getline(file,line);
numlines++;
...
Contrived example, for the sake of the question:
void MyClass::MyFunction( int x ) const
{
std::cout << m_map[x] << std::endl
}
This won't compile, since the [] operator is non-const.
This is unfortunate, since the [] syntax looks very clean. Instead, I have to do something like this:
void MyClass::MyFunction( int x ) const
{
...
I would like to use a parsed value as the input to a loop parser.
The grammar defines a header that specifies the (variable) size of the following string. For example, say the following string is the input to some parser.
12\r\nTest Payload
The parser should extract the 12, convert it to an unsigned int and then read twelve char...
I'm working as a TA in an introductory programming class, and the students tend to submit their programs as either one line, or without any indentation. Is there any tool that allows me to insert indents and things like that automatically? (We're using C++ and VisualStudio)
...
I'm trying to make a button but it always looks like windows 95 flat button. How do I make it look vista style?
hWndEdit = CreateWindowA("button", "Test",
WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
100, 20, 140, 20, hWnd, NULL, NULL, NULL);
Where ami I going wrong?
Thanks
...
So, I'm making a program to test the efficiency of certain data structures. I have all the .h files and I made a very terrible makefile that probably is wrong, although it seems to work up to a point. Instead of making .o files it makes .gch files, so when it tries to acces all the .o files they are not found. This is my makefile
pro...
I'm trying to build a very simple c++ program in eclipse and I'm getting a very silly error:
**** Internal Builder is used for build ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -oMyFirst.o ../MyFirst.cpp
g++ -oLinkedLists MyFirst.o
ld: unknown option: -oLinkedLists
collect2: ld returned 1 exit status
Build error occurre...
Hi,
i want to get the running process in .net compact framework windows mobile..
i want to kill the running process.. but i know process.GetProcessesByName() function
is present in desktop, but for mobile its not supported i think so..
please let me know how to kill the presently running process in c# windows mobile.
Thanks
...
I am writing a Qt application that has to handle big QImage s.
QImage uses implicit sharing, which means it reference counts an internal data pointer. Whenever the refcount is > 1 the object counts as "shared" and any even only potentially data modifying call issues a deep copy of the image data.
In short: I don't want deep copies to h...
Im new to the Qt library and i was going through the demonstrations. I came across this class without a destructor....
this is the cpp file
http://doc.trolltech.com/4.5/demos-mainwindow-mainwindow-cpp.html
and here is the .h file
http://doc.trolltech.com/4.5/demos-mainwindow-mainwindow-h.html
the constructor uses the new operator but ...
Hello.
I have to write a simple log class, that would write the output to a file.
I want it to work with overloading the << operator, so I can do this:
MyLog log("C:\\log.txt");
log<<"Message";
But Visual C++ tells me: "error C2039: '<<' : is not a member of 'MyLog' "
I don't know what I am doing wrong.
Here is the code:
MyLog.h
...
I´ve got problems with opening textures in SDL. I´ve got a function to read bmp files, optimize them and add colorkey:
SDL_Surface* SDLStuff::LoadImage( char* FileName ) {
printf( "Loading texture: \"%s\"\n", FileName );
SDL_Surface* loadedImage = 0;
SDL_Surface* optimizedImage = 0;
loadedImage = SDL_LoadBMP( FileName );
optimizedImag...
Hi,,
i have an app runnig in my win-mobile.. it has assosiated with many DLL's.
if i install app in storage card, all DLL and .exe comes to storage card only..
my requirement is if i take out storage card app should quit..
i am using c# .net 3.5 CF for development.
i will get notification tat storage card removed..but if i do KILL ...
Is there any equivalent function on OS X to SetTimer in Windows? I'm using C++.
So I'm writing a plugin for some software, and I need to have a funtion called periodically. On Windows I just pass the address of the function to SetTimer() and it will be called at a given interval.
Is there an easy way to do this on OS X?
It should be as ...
Hello,
My question (which will follow after this, sorry about the long intro, the question is down there in bold) is originally inspired by Item 23 in Herb Sutters Exceptional C++ where we find something like this:
<snip>
...
int main()
{
GenericTableAlgorithm a( "Customer", MyWorker() );
a.Process();
}
with
class GenericT...
I have an object that reads from a socket continuously like below:
void CSocketReader::ReadComplete ( )
{
messageProcessor->ResponseReceived ( response );
read ();
}
void CSocketReader::read()
{
socket.read(response);
}
My problem is, depending on the response and on the protocol that I am executing the ResponseReceived method cou...
I have a class that requires a non-default copy constructor and assignment operator (it contains lists of pointers). Is there any general way to reduce the code duplication between the copy constructor and the assignment operator?
...
Given a fairly complex object with lots of state, is there a pattern for exposing different functionality depending on that state?
For a concrete example, imagine a Printer object.
Initially, the object's interface lets you query the printer's capabilities, change settings like paper orientation, and start a print job.
Once you start ...
Hi,
I'm trying to set transparent icons in a QAction, which is then added to a Menu and a toolbar. I'm styling the application with a style sheet. The icon transparency works, but the icons are being drawn on the toolbar with what looks like a 1px black border on the left and top edges of the icons.
Now, all my icons are stored in one...