c++

how to copy folder from one path to another in c++

HI...Can any one provide me the code for how to copy the folder from one directory to another...i am able to copy the files by this code but i cannot copy the entir folder at a time... FILE *in, *out; char ch; if((in=fopen(sour->getfilepath(), "rb")) == NULL) { printf("Cannot open input file.\n"); getch(...

Ambiguity between IID_IDropTarget and Virtualtrees::IID_IDropTarget

I'm currently going through a process of refactoring includes to reduce compile time, and I've come across the following compile error: [C++ Error] some_class.cpp(53): E2015 Ambiguity between 'IID_IDropTarget' and 'Virtualtrees::IID_IDropTarget' The line of code it points to is: if (iid == IID_IUnknown || iid == IID_IDropTarget) If...

c++: following piece of code crashes

#include <iostream> using namespace std; class B { public: B() { cout << "Base B()" << endl; } ~B() { cout << "Base ~B()" << endl; } private: int x; }; class D : public B { public: D() { cout << "Derived D()" << endl; } virtual ~D() { cout << "Derived ~D()" << endl; } }; int main ( void ) { B* b = new D; de...

How to decode huffman code quickly?

I have implementated a simple compressor using pure huffman code under Windows.But I do not know much about how to decode the compressed file quickly,my bad algorithm is: Enumerate all the huffman code in the code table then compare it with the bits in the compressed file.It turns out horrible result:decompressing 3MB file would need 6 ...

Overloading the global type conversion operator

To test and display the result of some functions of my library, I am creating a set of handy functions. I have an execute function that looks like : template <typename R, typename I> std::string execute( const std::string& func_name, R(*func_ptr)( const I& ), const I& func_input ); It calls the function, and display the results and a...

C++ XML Schema Code Generator

We have XML files and we want to have C++ classes generated out of XML schema like we have it in .NET xsd. Also the generated classes instance needs to provide appropriate XML by calling some methods. ...

Simple C++ syntax question about colon

Hi everyone, I just saw a code snippet with a piece of syntax that I have never seen before. What does bool start : 1; mean? I found it inside a class definition in a header file. ...

Looking for QT styling with borderless window Tutorial or how to

Hello all im new to qt c++ i downloaded the latest windows version dome some tutorials and its great i saw some styling options that the qt framework has and its great , but now i need to build my application that its main windows (form) it designed/skinned with image without the rectangle borders (borderless ? ) . how can i do it wit...

Accessing protected method from derived class in a different project (C++) generates linker error

I'm developing in native C++, using visual studio. I have one project which contains infrastructures - base classes which I want to derive classes from in other projects in the same solution. Say I have a base class in the infrastructres project: file base.h: class Base { public: void Foo(); protected: ...

How to assign a string to char *pw in c++

How to assign a string to char *pw in c++ like... char *pw = some string ?? ...

XML in C++ Builder 6

How can I use XML as a simple data storage in Borland C++ Builder 6? Is there an internal class, which I could use? Thank's for help ...

How to explain undefined behavior to know-it-all newbies?

There'a a handful of situations that the C++ standard attributes as undefined behavior. For example if I allocate with new[], then try to free with delete (not delete[]) that's undefined behavior - anything can happen - it might work, it might crash nastily, it might corrupt something silently and plant a timed problem. It's so problema...

how do I write a logger class with cout style interface (logger << "Error: " << val << endl;)

I want to create a logger class such that with a functionality like this: Logger log; log << "Error: " << value << "seen" << endl; This should print me a custom formatted message. E.g. "12-09-2009 11:22:33 Error 5 seen" My simple class currently looks like this: class Logger { private: ostringstream oss; public: ...

Storing function pointers

The following uses a simple function pointer, but what if I want to store that function pointer? In that case, what would the variable declaration look like? #include <iostream> #include <vector> using namespace std; double operation(double (*functocall)(double), double wsum); double get_unipolar(double); double get_bipolar(double); ...

Winsock2 recv() hook into a remote process.

Hello! I was trying to hook a custom recv() winsock2.0 method to a remote process, so that my function executes instead of the one in the process, i have been googling this and i found some really good example, but they lack description typedef (WINAPI * WSAREC)( SOCKET s, char *buf, int len, int flags ) = recv; Now my question is, wh...

ActiveX code from Visual C++ port to Borland C++ Builder

I have the following code example for Visual C++ which creates an ActiveX object which can then be used. // create a smart pointer for ActiveDSO _DActiveDSOPtr activeDSO; HRESULT hr = activeDSO.GetActiveObject(__uuidof(ActiveDSO)); if (FAILED(hr)) { hr = activeDSO.CreateInstance(__uuidof(ActiveDSO)); if...

What is the difference between using a struct with two fields and a pair?

What is the difference regarding memory allocation and efficiency between using a struct with two fields and a pair? ...

C++: Easiest way to initialize an STL vector with hardcoded elements

I can create an array initialized with elements like this: int a[] = {10, 20, 30}; How do I create an STL vector and initialize it like the above? What is the best way to do so with the minimum typing effort? The best I can do is: std::vector<int> ints; ints.push_back(10); ints.push_back(20); ints.push_back(30); Though I could sh...

Crashing C++ application including ada dll does not generate core dump

How do I get a C++ application including a loaded ada shared library to generate a core dump? I have a C++ application which loads a ada shared library, inside the ada code I get a stack overflow error which causes program termination along with the console output: raised STORAGE ERROR No core dump file is generated even thou I have ...

deleting element (objects) within a vector (not referenced by pointer) , memory handling

hello experts, This is an extension of this question . I have searched on the web but couldn't find a satisfactory answer. I have a class A which defines a vector that contains a number of instances of class Region. The memory handling for these Region instances need to be managed by Class A My questions are: 1. In the following c...