c++

[.NET] How to load multiple mscorlib.dll and call their inner functions seperately?

This is for research purpose. I have .Net framework 2.0 installed, and I want to load mscorlib.dll 1.1 dynamiclly to execute its specific inner function. When I wrote this code in C#: static void Main(string[] args) { Assembly assem = Assembly.LoadFrom("C:\\mscorlib_my_private_1.1.dll"); System.Type type = assem...

Why is T() = T() allowed?

I believe the expression T() creates an rvalue (by the Standard). However, the following code compiles (at least on gcc4.0): class T {}; int main() { T() = T(); } I know technically this is possible because member functions can be invoked on temporaries and the above is just invoking the operator= on the rvalue temporary created...

virtual function

what are virtual functions? what is pure virtual function? please explain with example ...

Determine if a string contains only alphanumeric characters (or a space)

I'm learning C++ and I am writing a function that determines whether a string contains only alphanumeric characters and spaces. I suppose I am effectively testing whether it matches the regular expression ^[[:alnum:] ]+$ but without using regular expressions. I have seen a lot of algorithms revolve around iterators, so I tried to find a ...

Does operator precedence in C++ differ for pointers and iterators?

The code below demonstrates this difference: #include <iostream> #include <string> int main() { char s[] = "ABCD"; std::string str(s); char *p = s; while(*p) { *p++ = tolower(*p); // <-- incr after assignment } std::cout << s << std::endl; std::string::i...

Strange overloading rules in C++

I'm trying to compile this code with GCC 4.5.0: #include <algorithm> #include <vector> template <typename T> void sort(T, T) {} int main() { std::vector<int> v; sort(v.begin(), v.end()); } But it doesn't seem to work: $ g++ -c nm.cpp nm.cpp: In function ‘int main()’: nm.cpp:9:28: error: call of overloaded ‘sort(std::vector<...

Profiler for IAR EW for ARM

I am trying to get the profiler plug-in for IAR Embedded Workbench for ARM to work. I have set everything in the documentation but when I fire up C-Spy and start the plug-in I get errors. I tried to different emulators and each gave a different error: Segger SAM-ICE JTAG Emulator - The following appears in the debug log: Thu May 27 12:...

Developing a sector based partition copying program?

Hi, I want to develop a program that copies a partition's 'data' only, to another partition. And I want to do it such that the program starts from the first sector of source partition and checks if a sector is used. If it is used copy it to the destination parition. Else don't copy. In other words it's like copying only th...

Confused about definition of a 'median' when constructing a kd-Tree

Hi there. Im trying to build a kd-tree for searching through a set of points, but am getting confused about the use of 'median' in the wikipedia article. For ease of use, the wikipedia article states the pseudo-code of kd-tree construction as: function kdtree (list of points pointList, int depth) { if pointList is empty retu...

Browser issue symbian

hi all, i want to show browser control in my application for which i have written code if (iBrCtlInterface == NULL) { TRect rect(Position(), Size()); iBrCtlInterface = CreateBrowserControlL( this, rect, TBrCtlDefs::ECapabilityDisplayScrollBar | TBrCtlDefs::ECapabilityLoadHttpFw, iCommandBase, NULL, NULL, NULL, NULL, NULL); } _LIT...

How to write a flexible modular program with good interaction possibilities between modules?

I went through answers on similar topics here on SO but could't find a satisfying answer. Since i know this is a rather large topic, i will try to be more specific. I want to write a program which processes files. The processing is nontrivial, so the best way is to split different phases into standalone modules which then would be used ...

sending data packet just before closing socket

Before disconnect the client, the server wants to send some info to the client - why do I(server) disconnect you(client). If I send packet to the info and close the client socket immediately, closesocket() returns -1 and if I use linger option to work closesocket() successfully, the info cannot be sent completely. How can I complete t...

Sleep Function Error In C

I have a file of data Dump, in with different timestamped data available, I get the time from timestamp and sleep my c thread for that time. But the problem is that The actual time difference is 10 second and the data which I receive at the receiving end is almost 14, 15 second delay. I am using window OS. Kindly guide me. Sorry for my...

Generation of .tlb Files in Windows 7 Pro 32-bit

I have a C++ DLL that imports a .tlb file generated in a C# project. The C++ DLL is a wrapper DLL containing functions that call the corresponding C# functions. When I call the C++ functions on the computer that I built the projects, all works well. But when I copy the DLL's and generated tlb's to another computer with the same exact ve...

Makefile issue with compiling a C++ program

I recently got MySQL compiled and working on Cygwin, and got a simple test example from online to verify that it worked. The test example compiled and ran successfully. However, when incorporating MySQL in a hobby project of mine it isn't compiling which I believe is due to how the Makefile is setup, I have no experience with Makefiles ...

How can I load scripts, styles and images from a non-URL source?

I am integrating WebKit (via Qt) into an application. Instead of having WebKit retrieve scripts, CSS files and images via URLs, I want my application to provide them (e.g. retrieved from a database). For example, a "regular" web page may contain this tag: <IMG src="photos/album1/123456.jpg"> Instead of WebKit fetching this image fr...

CArray doesn't call copy constructors on memory reallocations, now what?

Suppose I have a class that requires copy constructor to be called to make a correct copy of: struct CWeird { CWeird() { number = 47; target = &number; } CWeird(const CWeird &other) : number(other.number), target(&number) { } const CWeird& operator=(const CWeird &w) { number = w.number; return *this; } void output() ...

How to get a component's parent form in Borland VCL?

Hi, I'd like to determine which form a given component belongs to in my application. Neither the Parent nor the Owner property can be assumed to be the form itself, so I can't simply use this. I guess I could just go through the Parent property recursively until I arrive at something derived from TForm, but is there a better way to do ...

How can I combine pairs of elements from a std::set?

I have a set<string> from "one", "two", and "three". How can I get all pairs from it? one - two one - three two - three ...

boost::filesystem::path(std::wstring) throw exception

hi. this code: boost::filesystem::is_directory("/usr/include"); work fine. both this code: boost::filesystem::is_directory(L"/usr/include"); throw an exception: terminate called after throwing an instance of 'std::runtime_error' what(): locale::facet::_S_create_c_locale name not valid OS - Linux Mint boost-1.43 gc...