c++

Overloaded assigment operator is not getting called.

I have written a overloaded assignment operator of class perform copying all the variable values. For ex :in Exp.cpp class perform { LOG *ptr; int a; //constructor //destructor perform operator=(const perform & rhs){ ptr = rhs.ptr; a=rhs.s; return * this;} }; In another class output, I have declared a pointer for abc. perform...

C++ Templates compilation

I am failing to answer questions related to templates. Basically how templates are compiled by the compiler. I googled but did not find answers. Can somebody help me ...

Restart Mac OS X ungracefully using a C++ call?

How do I restart Mac OS X using C++ (not Objetive-C) without invoking any child processes? Don't care if it's ungraceful. system("reboot"); //Is not acceptable as it relies on invoking a process ...

C++ and CONST: How to use UINT32 in the typedef place of FLAG and use CONST FLAG flag; inside the structure?ong

Hello All, I am new to C++ programming. I am analyzing a code and I found the following: typedef unsigned short UINT16; typedef unsigned long UINT32; typedef UNIT16 FLAG; //within a structure, struct x { const FLAG& flag; //what this means?? }; When I change the FLAG datatype to UNIT32, then FLAG& is returning some other value...

C++ Boost serialization Serializing templated derived classes

Hi, i would like to serialize a class with an attribute as a list of pointers on a generic class This is the parent class from which the generic class derives : class Base{ public : friend class boost::serialization::access; virtual ~Base(){} template<class Archive> void serialize(Archive & ar, ...

Alternate way of computing size of a type using pointer arithmetic

Is the following code 100% portable? int a=10; size_t size_of_int = (char *)(&a+1)-(char*)(&a); // No problem here? std::cout<<size_of_int;// or printf("%zu",size_of_int); P.S: The question is only for learning purpose. So please don't give answers like Use sizeof() etc ...

convert int to std::string

Possible Duplicate: int to std::string? How can you convert int to std::string? ...

Problem with std::make_tuple in C++0x.

Tying to compile the following program with Visual Studio 10, I get lot of compile errors: #include "stdafx.h" #include <tuple> #include <string> #include <map> #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { typedef std::tuple<std::string, std::string> key_t; typedef std::map<key_t, std::string> map_t; map_t t...

arbitrary datatype ratio converter

I have following code: template<typename I,typename O> O convertRatio(I input, I inpMinLevel = std::numeric_limits<I>::min(), I inpMaxLevel = std::numeric_limits<I>::max(), O outMinLevel = std::numeric_limits<O>::min(), O outMaxLevel = std::numeric_limits<O>::max() ) { double inpRange = abs(double(inpMaxLevel - inpMi...

Include header files from command line (gcc)?

Is it possible to specify extra header files to include from the command line (using GCC 4 / C++)? Or is there any other way files can be included except with #include? Background: I'm trying to compile a large code base on my own PC. The code is usually compiled in a cluster, with a complicated build system (SoftRelTools anybody?), wh...

Upload music to iPhone/iPod/... directly without iTunes

Hello, is it possible to program a tool that sends music to iPhone/iPod without putting the songs in iTunes? the tool can work with "iTunes SDK" andit is not attended to go against Apple rules the idea is to not "cache" the songs as iTunes in libraryes, just upload it directly to the iPhone/iPod from file server this help if have musi...

size of struct without use sizeof keyword

here is code which returns size of struct without using sizeof keyword #include <iostream> using namespace std; struct point{ int x; int y; }; struct point pt={0,0}; int main(){ point *ppt=&pt; unsigned char *p1,*p2; p1=(unsigned char *)ppt; p2=(unsigned char *)++ppt; printf("%d",p2-p1); retur...

Use gdb console in eclipse

Is there a way how I can access gdb's console in eclipse? I would like to just be able to set breakpoints with the mouse and then use the console for debugging. ...

Can any one give a screen shot of how and where we can enable /clr:pure option in visual studio 2008?

Can any one give a screen shot of how and where we can enable /clr:pure option in C++ project visual studio 2008? Please... ...

using SWIG with C++

HI all I am trying to use SWIG to export C++ code to Python. The C sample I read on the web site does work but I have problem with C++ code. Here are the lines I call swig -c++ -python SWIG_TEST.i g++ -c -fPIC SWIG_TEST.cpp SWIG_TEST_wrap.cxx -I/usr/include/python2.4/ gcc --shared SWIG_TEST.o SWIG_TEST_wrap.o -o _SWIG_TEST.so -lstdc+...

optimization, branching elimination

float mixValue = ... //in range -1.0f to 1.0f for(... ; ... ; ... ) //long loop { float inputLevel = ... //in range -1.0f to 1.0f if(inputLevel < 0.0 && mixValue < 0.0) { mixValue = (mixValue + inputLevel) + (mixValue*inputLevel); } else { mixValue = (mixValue + inputLevel) - (mixValue*inputLevel)...

Library for electrical network simulation

I'm searching for a free and open source library for electrical network simulation. In (Per preference order) : Python, Ruby, Javascript, PHP, C++ (with Qt if it exist) or bash (ahah). Do you know one ? ...

OpenCV HoughCircles

Hi there Im using Xcode and c++ I have copied the HoughCircles code from the OpenCV documentation: #include <cv.h> #include <highgui.h> #include <math.h> using namespace cv; int main(int argc, char** argv) { Mat img, gray; if( argc != 2 && !(img=imread(argv[1], 1)).data) return -1; cvtColor(img, gray, CV_BGR2GRAY...

MSVC: Implicit Template Instantiation, though templated constructor not used

Hello, I am trying to compile Flusspferd on Windows using MSVC, but it fails due to a template instantiation problem. For the ease of explanation I rewrote the problem in simpler terms: #include <boost/utility/enable_if.hpp> #include <boost/type_traits/is_convertible.hpp> class UndefinedType; class A { }; class TestClass { public: ...

Express operation taking vector in Visio UML diagram

How do I represent the following design using Visio 2003's UML tools? #include <vector> template<class T> class Test { public: bool write(const std::vector<T> & data); }; I have created a parameterized classes for std::vector and Test and an operation for write(), but when I'm not sure how to add the parameter to write(). ...