c++

c++ global operator not playing well with template class

ok, i found some similar posts on stackoverflow, but I couldn't find any that pertained to my exact situation and I was confused with some of the answers given. Ok, so here is my problem: I have a template matrix class as follows: template <typename T, size_t ROWS, size_t COLS> class Matrix { public: template<typename, ...

comparing two end() iterators

list<int> foo; list<int> foo2; list<int>::iterator foo_end = foo.end(); list<int>::iterator foo2_end = foo2.end(); for (list<int>::iterator it = foo.begin(); it != foo2_end; ++foo) <- notice != comparison here { ... it this allowed? will it work correctly. I am inclined to think that this is implementation dependent, anyone knows ...

How to acquire still webcam image

I need some help deciding what to use to acquire an image from a webcam. I want to acquire a single image. I know you can typically acquire a still image at a higher resolution than a single video frame. Currently, I am using MATLAB's image acquisition toolbox.. which apparently only supports obtaining frames in video mode(so lower res...

Where is pure virtual function located in C++?

Which virtual table will be pure virtual function located? In the base class or derived class? For example, what does the virtual table look like in each class? class Base { virtual void f() =0; virtual void g(); } class Derived: public Base{ virtual void f(); virtual void g(); } ...

Where can we use "This" in Recursion methode...

Hi . I have a methode in a static class which try to convert bi*nar*y tre to list I'd like to make a recusion but I couldn't I've implemented some opertation in my class like add,delet,find.it's too easy to implement its . Here is the code class ARB { private: struct BT { ...

How to keep only duplicates efficiently?

Given an STL vector, output only the duplicates in sorted order, e.g., INPUT : { 4, 4, 1, 2, 3, 2, 3 } OUTPUT: { 2, 3, 4 } The algorithm is trivial, but the goal is to make it as efficient as std::unique(). My naive implementation modifies the container in-place: My naive implementation: void not_unique(vector<int>* pv) { if (!...

Floating point vs integer calculations on modern hardware

I am doing some performance critical work in C++, and we are currently using integer calculations for problems that are inherently floating point because "its faster". This causes a whole lot of annoying problems and adds a lot of annoying code. Now, I remember reading about how floating point calculations were so slow approximately cir...

traversing a directory

Is there any way to traverse the content of a directory? I would like to store the names of each folder in a given directory. Thanks! ...

When pass-by-pointer is preferred to pass-by-reference in C++?

I can imagine one case, in which the input parameter could be NULL so that pass-by-pointer is preferred but not pass-by-reference? Can anybody add more cases? ...

How to use external makefile in Eclipse

Hi all! I have a source code of an OpenSource project which I get from SVN. I was able to run autogen --> configure --> and make successfully (through the terminal). But I want to build the same project with Eclipse, and I can't port manually those source files to eclipse though. So, How can I set Eclipse to use external make files ? ca...

i want to know VC++ 6.0 uses .Net frame work or not?

i am doubtful about it that vc++6.0 is .Net framework independent or depends on it help required? ...

How to capture full screen in c using visual studio

Is it possible to capture full screen in visual studio (VC++), so that user don't have to press ATL+Enter. Kindly guide me how I can make it possible. ...

"call" instruction that seemingly jumps into itself

I have some C++ code #include <cstdio> #include <boost/bind.hpp> #include <boost/function.hpp> class A { public: void do_it() { std::printf("aaa"); } }; void call_it(const boost::function<void()> &f) { f(); } void func() { A *a = new A; call_it(boost::bind(&A::do_it, a)); } which gcc 4 compiles into the following as...

Why isnt the copy constructor of member class called?

class member { public: member() { cout<<"Calling member constr"<<'\n'; } member(const member&) { cout<<"Calling member copy constr"<<'\n'; } }; class fred { public: fred() { cout<<"calling fred constr"<<'\n'; } fred(const fred &) { cout<<"Calling fred copy constr...

i have a win32 windows application and want to capture full screen and remove the border of window displayed ?

win32 windows application and want to capture full screen and remove the border of window displayed any one tell me how can i do so if this window capture the mouse keyboard controls then it will be ideal? // MonitorScreen.cpp : Defines the entry point for the application. // include "stdafx.h" include "MonitorScreen.h" define MAX_L...

DIfferentiate Between Windows Service Startup as part of System reboot and Service stop/start using sc tool

Hi, How do I differentiate in my C++ code between a service coming up as a part of system reboot and service coming up since the user stopped and started the service manually in service manager or using sc tool???? ...

Java and C++ on Stack Unwinding issue

As far as I know, in case of an uncaught exception, C++ destroys the local variables immediately, Java releases the references and leaves the rest for the garbage collector. Is this right? What exactly is the difference between Java and C++ on this issue? in other words, which of these two languages is considered better in terms of stac...

function pointer error

Can anybody help me with this simple code?? #include <iostream> using namespace std; void testFunction(){ cout<<"This is the test function 0"<<endl; } void testFunction1(){ cout<<"This is the test function 1"<<endl; } void testFunction2(){ cout<<"This is the test function 2"<<endl; } void (*fp[])()={testFunction,testFunc...

Generate accessors in Visual C++ 2008

Hi, I'm trying to generate the accessors and mutators for my variables automatically, but just can't find a way. I tried the right-click/refactor... solution, but the refactor item doesn't appear. I'm not in the mood right now to learn how to write a macro to do this, and I don't have the money to buy a commercial solution (internship s...

visual studio macro - getting started | copy a definition from .cpp to .h

Is it possible to do a macro that copies a definition of a function to a declaration(, and maybe also the opposite)? For instance Foo::Foo(int aParameter, int bParameter){ // } int Foo::someMethod(char aCharacter) const { return 0; } from the .cpp file would be: class Foo { Foo(int aParameter, int bParameter); i...