c++

Why aren't template specializations allowed to be in different namespaces?

Hi, Please, see what I am trying to do: #include <iostream> namespace first { template <class T> class myclass { T t; public: void who_are_you() const { std::cout << "first::myclass"; } }; } namespace second { using first::myclass; template <> class myclass <int> { int i, j; public: void who_are_you() const { std...

difference between (++i) and (i++)

I understand that (++i) should return a reference to i because the need of concatenation of operators, but what I can't figure out is: Why (i++) should return i by value? can anyone please clarify. Thank you *edit: i forgot to mention that i mean c++ ...

Long long int on 32 bit machines

Hi,very simple question, I read that GCC supports long long int type. But how can make math operations with it, when CPU is 32 bit wide only? ...

Displaying Unicode/ASCII Characters on console or window

I couldn't display a 'bullet' of character code DEC 149 which can be found on ASCII Chart. cout << char(149) << endl; it comes out as ò on console window. I know a few characters from charmap that I'd like to use but how would i know their character codes? ...

Error in ATL Project generated header with importlib

I need to importlib a VB6 dll for consumption by an ATL component. I'm not able to use the MIDL import keyword for various reasons. I'm getting a C2061 error in my project in the generated header file (test_i.h) : syntax error: identifier '_MyDataType'. My idl file is import "oaidl.idl"; import "ocidl.idl"; [ uuid(8BB809C6-B5EC-48B1-9...

Writing JPEG image from BLOB field

Hi, I've got a BLOB field in a MySQL database that I need to fetch and write into a .jpg file. I already know how to query the database and get the result, but I can't write it into a valid .jpg file. Anyone got any help? Thanks ...

How to count lines of a file in C++?

Hi, In C++, how can I count lines using the standard classes fstream, ifstream? Thank you, Mohammad ...

boost::this_thread::sleep() vs. nanosleep()?

I recently came across the need to sleep the current thread for an exact period of time. I know of two methods of doing so on a POSIX platform: using nanosleep() or using Boost::this_thread::sleep(). Out of curiosity more than anything else, I was wondering what the differences are between the two approaches. Is there any difference i...

Does it feel anytime that c++ sometimes reduces problem solving time and increases syntactic, semantic rigor ??

C++ introduces OOPS, templates and variety of other concepts. But sometimes I am stuck in unmanageable storm of calling convention incompatibilities between methods, convoluted casting between distantly connected classes and struggling with code that forces me think in the level of byte-alignment. I am very tempted to go back to plain ...

Have to use C# dll to call C++ dll?

Do I have to create a C# DLL to call C++ DLL or I can call it directly from my C# application? ...

Create and use HTML full text search index (C++)

I need to create a search index for a collection of HTML pages. I have no experience in implementing a search index at all, so any general information how to build one, what information to store, how to implement advanced searches such as "entire phrase", ranking of results etc. I'm not afraid to build it myself, though I'd be happy t...

Capture stdin input without echoing characters to screen

I have a very simple code: char character; std::cin >> character; However, I would like it to behave as follow: Don't echo to console the character I type std::cin should return (unblock) right away when a character is pressed without having to press the Enter key Is this possible? I also have access to Qt. ...

Dynamic creating of typedef

Hello, I'm creating event system. It's based under boost::signals. To make the work easier I'm using typedef for the function signatures. Everything is okey until I need creating of some new event trought event's system method. I have to create the typedef dynamically on given type to the template function. The problem is the name of ty...

Creating an Ctablctrl on a CFrameWnd

hi im new here, I want to create a mfc window that has tabs on top. I cannot find a good tutorial or example of this. Can someone give me a link to a good tutorial of example? please help me. ...

Official C++ language subsets

I mainly use C++ to do scientific computing, and lately I've been restricting myself to a very C-like subset of C++ features; namely, no classes/inheritance except complex and STL, templates only used for find/replace kinds of substitutions, and a few other things I can't put in words off the top of my head. I am wondering if there are a...

How can I extract the domain from a URL?

I'm currently making a few changes in the rTorrent source. I have the following code: torrent::Object apply_to_domain(const torrent::Object& rawArgs) { const char * url = rawArgs.as_string().c_str(); char buffer[50]; snprintf(buffer, 50, "URL: %s.", url); return std::string(buffer); } I need to extract the domain from url. Ther...

Variable assignment in 1st condition and using same variable in 2nd condition Well defined?

Is this well defined? Streamreader ^reader = gcnew Streamreader("test.txt"); String ^line; while ((line = reader->ReadLine()) != nullptr && line != "") { //do stuff } I believe that I read somewhere that it is not guaranteed that the assignment is executed before the 2nd conditional. It may be that I'm wrong or that this just ap...

Show System Menu From Another Window

The project I'm working on right now is essentially an open source version of Ultramon (the multiple taskbar program). Thus think of the application to be just like the windows taskbar. Buttons for each window, etc. This is coded in C/C++ using WinAPI I've just started doing it, and have some of the functionality down. However, I'm get...

getting value of clicked point wxFreeChart

Hello, Does anyone know how can I get value of clicked point on wxFreeChart plot ? Thanks for any hint. In documentation (http://wxcode.sourceforge.net/docs/freechart/) there is soemthing like: bool AxisPlot::ToDataCoords ( size_t nData, wxDC & dc, wxRect rc, wxCoord gx, wxCoord gy, double * x, double * y ) ...

Horizontal mouse wheel event? (WinAPI)

My laptop has a trackpad that can do horizontal scrolling aswell as vertical (WM_MOUSEWHEEL) . How can I handle horizontal scrolling? Thanks ...