c++

Storing objects in STL vector - minimal set of methods

Hello What is "minimal framework" (necessary methods) of object, which I will store in STL <vector>? For my assumptions: #include <vector> #include <cstring> using namespace std; class Doit { private: char *a; public: Doit(){a=(char*)malloc(10);} ~Doit(){free(a);} }; int main(){ vector<Doit> v(10);...

Is there any algorithm for turning simple HAXE code into C/C++ code files?

I have simple Haxe app like class Main { public static function main() { trace("hello world"); } } I know how to compile such app for windows (not as SWF but as app from pure C\C++ )(and you can see how here but be worned thay use hxcpp\0,4 ) The problem is - I do not want to compile app for Windows Vista or 7 or XP I want to get PUR...

Unresolved externals with explicit template instantiations. What is the declaration syntax?

Here's some simplified code to demonstrate the problem I have. I have a template function for which I only wish to compile certain fixed instantiations. The function declarations are: // *** template.h *** int square (int x); double square (double x); The definitions are: // *** template.cpp *** #include "template.h" // (template ...

event handling for button click in visual c++

i am new to this platform and i want to retrive the data from textfield on the click of a button ,how to do this please help me ...

Why does std::cout convert volatile pointers to bool?

If you try to cout a pointer to a volatile type, even a volatile char pointer where you would normally expect cout to print the string, you will instead simply get '1' (assuming the pointer is not null I think). I assume output stream operator<< is template specialized for volatile pointers, but my question is, why? What use case motivat...

Exception Specification

I know that this feature will be deprecated in C++0x, but for me as a total novice it seems like a good idea to have it. Could anyone explain to me why isn't a good idea? ...

Inline functions in C++

If we define a member function inside the class definition itself, is it necessarily treated inline or is it just a request to the compiler which it can ignore. ...

subtract one image from another using openCV

How can I subtract one image from another using openCV? Ps.: I coudn't use the python implementation because I'll have to do it in C++ ...

Visual C++ Enable Console

I created an Empty Project in Visual C++, but now I need the Console to display debug output. How can I enable the Console without recreating the project or show the output in the VS output window? Thanks in advance Attic ...

Undefined behavior on deleting char array trought void *

Hello! Is it correct that following yields undefined behavior: void * something = NULL; char * buffer = new char[10]; something = buffer; buffer = NULL; delete [] something; // undefined?? Do I first need to cast something to char * ? Thank you! ...

Destructors in C++

Does the destructor deallocate memory assigned to the object which it belongs to or is it just called so that it can perform some last minute housekeeping before the object is deallocated by the compiler? ...

C++ polymorphism, function calls

Okay, I'm pretty inexperienced as a programmer, let alone in C++, so bear with me here. What I wanted to do was to have a container class hold a parent class pointer and then use polymorphism to store a child class object. The thing is that I want to call one of the child class's functions through the parent class pointer. Here's a sort ...

Can boost::asio only receive full UDP datagrams?

I am working on a UDP server built with boost::asio and I started from the tutorial customizing to my needs. When I call socket.receive_from(boost::asio::buffer(buf), remote, 0, error); it fills my buffer with data from the packet, but, if my understanding is correct, it drops any data that won't fit in the buffer. Subsequent calls to re...

Which programming languages support constant methods?

Which programming languages other than C++ support the concept of a constant class method? That is, what languages allow the programmer to constrain a method in such a way that it is guaranteed not to change the state of an object to which the method is applied? Please provide examples or references in your answer. ...

Profiling shared library/plugins written in C++ for Python?

I've got a C++ library that lets me write plugins in C++ and then automatically exposes them to python. I'm working on some networking stuff in a plugin and I'd like to profile it with something like gprof, but simply compiling with -pg and running the plugin via python doesn't generated the necessary profiling data. Unfortunately the ...

Code Usage Analysis Tool

Is there any available (free) too to scan a bunch of C++ code and output a listing of all the classes and methods used? I don't need it to do anything advanced, or compile it, I just want any easy way to generate a basic list of classes/methods, so that I can compare that list to a similar codebase and see what is used in both. ...

Setting an std::string variable value from gdb?

Is it possible... when the debugger is stopped at a breakpoint, to modify the value of a std::string variable without resorting to hacks like tweaking the memory image of the current buffer? e.g. something like "set var mystring="hello world" ? ...

The cost of passing by shared_ptr

I use std::tr1::shared_ptr extensively throughout my application. This includes passing objects in as function arguments. Consider the following: class Dataset {...} void f( shared_ptr< Dataset const > pds ) {...} void g( shared_ptr< Dataset const > pds ) {...} ... While passing a dataset object around via shared_ptr guarantees its e...

ChaiScript troubles

Hello guys, I'm using script language ChaiScript with c++ and Qt. I've defined such function: void ChaiPainter::drawRectangle(QPainter *painter, int x, int y, int height, int width) { painter.drawRect(x, y, width, height); } And in application paint-event: void MainWindow::paintEvent(QPaintEvent *event) { QPainter painter(thi...

Using boost.python to import a method with opencv calls but failing due to symbols not being found after compilation

So I don't have the code right now, as I am not home... but i used the boost library for python in C++ to allow python to access a function called something like loadImageIntoMainWindow(string filepath) in the C++ source code the method calls opencv methods that are imported at the top of the file, I included opencv in my Jamroot file, ...