c++

non-static vs. static function and variable.

Hi, I have one question about static and non-static function and variable. 1) non-static function access static variable. It's OK! class Bar { public: static int i; void nonStaticFunction() { Bar::i = 10; } }; int Bar::i=0; 2) non-static function access non-static variable Definitely OK! 3) static fu...

why does c++ have its separate syntax for new & delete?

Why can't it just be regular function calls? New is essentially: malloc(sizeof(Foo)); Foo::Foo(); while delete is Foo:~Foo(); free(...); So why does new/delete end up having it's own syntax rather than being regular functions? ...

2 quick questions about passing by const pointer/const reference

1) Can someone explain the following? void OnCreate(HWND hWnd, const LPCREATESTRUCT lpCreateStruct) { lpCreateStruct->x = 2; // this compiles } void OnCreate(HWND hWnd, const CREATESTRUCT * lpCreateStruct) { lpCreateStruct->x = 2; // this does not compile } 2) Is it faster to pass by pointer or by reference? Or the same? ...

Embedding a file into a program.

I want to embed a file in a program. It will be used for default configuration files if none are provided. I have realized I could just use default values, but I want to extract the file and place it on the disk so it can be modified. ...

Free Lightweight IDE/Text Editor for Windows - C++ Development

I have searched a lot for the exact development tool that fits my requirements, but could not find it anywhere. Here are my requirements: 1) Free. 2) Lightweight. (Eclipse is out). 3) Can handle a large project. 4) Input: Just the source tree, and possibly makefiles. No project/solution files. 5) Indexing - Auto Completion and "Go ...

Classes, Static Methods, or Instance Methods - Memory Consumption and Executable Size in Compiled Languages?

I keep wondering about this to try to improve performance and size of my Flex swfs, how do classes vs. static methods vs. instance methods impact performance and the final compiled "executable's" size? Thinking how it might be possible to apply something like HAML and Sass to Flex... Say I am building a very large admin interface with...

Templates vs. Action Hierarchy

I'm creating a button class and am having a hard time deciding between 2 solutions. 1) Templatize the Button class and have it take a function object in its constructor to call when the button is pressed. The guy I'm coding with is worried that this will lead to code bloat/thrashing. 2) Create a ButtonAction base class, and there will ...

how to use processor registers in visual studio ?

i'm trying to write a program that solves the rsa challenge (yes i have interesting goals) and currently i don't have a 64 bit linux box and i don't really wanna spend my time writing a program that doesn't have a chance to ever finish. so while i can do some assembler programming, i would prefer using C++. however, i would also be inter...

Inserting a std::list element to std::list

std::list <std::list <int>> mylist; std::list <int> mylist_; mylist_.push_back(0); mylist.push_back(mylist_); is it possible to insert a sub-list into the list (mylist) without creating the temporary local sub-list (mylist_) and would it be better to use the type (sub-list) as pointer in list (mylist) in terms of per...

How to Place DialogBar or Dialog box into pane in vc 2008 or vc 2010 Beta

Hi now i am working in 2003 vc++ and i am converting(migrating) my project in to vc 2008 or new vc 2010 Beta,i saw the feature pack of 2008,2010 regards CDockable Pane(Auto Hode,floating),so i require this features ,i want to place a dialogbox or dialog bar into pane(CDockable Pane class), so i done this in my following code Myframe Cod...

Boost regular expressions

Does anyone know of any good tutorials on regular expressions using boost? I have been searching for a decent one, but it seems most are for people who know a little about regular expressions ...

Network programming using C++

Hi, How can we do network programming in C++ similar to Remoting in .NET? Please help with any tutorials. It would be fine if I know how to enable two computers to communicate in the form of sending and receiving messages using C++/C#. Thanks, Rakesh. ...

getting input numbers from the user

How can I get input from the user if they are to separate their inputs by whitespace (e.g. 1 2 3 4 5) and I want to put it in an array? Thanks. Hmmmm. I see most of the responses are using a vector which I guess I'll have to do research on. I thought there would be a more simpler, yet possibly messier response since we haven't cover...

C++ Two Dimensional std::vector best practices

I am building an app that needs to have support for two dimensional arrays to hold a grid of data. I have a class Map that contains a 2d grid of data. I want to use vectors rather than arrays, and I was wondering what the best practices were for using 2d vectors. Should I have a vector of vectors of MapCells? or should it be a vector of ...

Thread type for background drawing to a bitmap in MFC

I have a MFC document/view C++ graphics application that does all its drawing to an off screen bitmap, and then copys that to the supplied CDC pointer in the OnDraw method. Over the last couple of days I've been looking to place the drawing component in a seperate worker thread, so it doesn't stall the GUI. I seem to get a fair number ...

How to read integers from a file, line by line in C++

I have a text file with on every line one or more integers, seperated by a space. How can I in an elegant way read this with C++? If I would not care about the lines I could use cin >>, but it matters on which line integers are. Example input: 1213 153 15 155 84 866 89 48 12 12 12 58 12 ...

How to convert UTF-8 <-> UTF16 portable

Hi, is there a simple, portable way (win32, linux at least) to convert UTF-16 to UTF-8 and back? Preferably using boost. Thx for your help, Tobias ...

C++ socket windows

Hello all , I have question. I create socket , connect , send bytes , all is ok. and for receiving data i use recv function. char * TOReceive= new char[200]; recv(ConnectSocket, TOReceive , 200, 0); when there are some data it reads and retuns, succefull , and when no data waits for data, all i need to limit waiting time, for ex...

Using C++/Qt4 application as backend for web application

Hello, for one of my applications I'd like to provide a minimal web interface. This core application is written in C++ and uses Qt4 as a framework. Since I'm also using some libraries I wrote to calculate some things and do some complex data management, I'd like to use this existing code as a backend to the web interface. Idea 1: Using...

OCR Application for Android

Hi I am a final year engineering student from India. Working on a project to develop an application to perform OCR on English Text on an Android mobile phone. I am hoping to use an existing open source OCR engine. like tesseract for example. Can anyone please help me? point me in the right direction? this is my first ever project. ...