c++

question about auto_ptr::reset

please can anybody explain this code from C++ Reference site: #include <iostream> #include <memory> using namespace std; int main () { auto_ptr<int> p; p.reset (new int); *p=5; cout << *p << endl; p.reset (new int); *p=10; cout << *p << endl; return 0; } ...

does adding a dummy parameter to constructors of a class to solve calling ambiguity, violate any rule ?

take following class and two object definitions: class Rect{ public: enum centimeter; enum meter; Rect(double len,double wid,enum centimeter){ length=(len/100); width=(wid/100); } Rect(int len,int wid,enum meter){ length=len; width=wid; } //rest of implementation private: double length;//in meters double ...

Perspective and Bilinear transformations

I'm making a vector drawing application and noticed that Anti Grain Geometry have an example that does exactly what I want. http://www.antigrain.com/demo/index.html then below there is an example on perspective for Win32. I don't understand their cpp file. Based on this example. If I have a bunch of verticies to form an object, like thei...

Accessing a static member that has the same name as an inner type.

I have a few classes that define sequences whose values must be available both at compile-time through a value member and at runtime as an actual instance of the type. So my base types for an arithmetic sequence looks a little like this, template<int A, int D> struct ArithmeticSequence : public Sequence { ArithmeticSequence(VALUE v)...

A boot loader in C++

Hello, I have messed around a few times by making a small assembly boot loader on a floppy disk and was wondering if it's possible to make a boot loader in c++ and if so where might I begin? For all I know im not sure it would even use int main(). Thanks for any help. ...

c++ multithreaded task queue for scheduled tasks

I need to develop a module which will execute scheduled tasks. Each task is scheduled to be executed within X milliseconds. The module takes as a parameter an amount of worker threads to execute the tasks. The tasks are piled up in a queue which will probably be a priority queue, so a thread checks for the next-in-queue task (the one w...

Is it possible to transform the types in a parameter pack?

Is it possible to transform the types of a parameter pack and pass it on? E.g. given the following: template<class... Args> struct X {}; template<class T> struct make_pointer { typedef T* type; }; template<class T> struct make_pointer<T*> { typedef T* type; }; Can we define a template magic or something similar so that the follow...

how do I check if input from cin is a double?

Possible Duplicates: How to validate numeric input C++ how do I validate user input as a double in C++? I need to get input from the command line and check if it is a valid number... storing it as a double. If the input is invalid, I need to keep asking for a number. double x; cout << '>'; cin >> x; while (/*x is invalid*...

C++ CppUnit Test (CPPUNIT_ASSERT)

I'm trying to do up a screen scraping assignment. My cpp works, but I don't know how to integrate my unit testing. I tried to do a bool check unit test for the file validity but it's giving me this error: error: cannot call member function 'bool ScreenScrape::getFile()' without object screenscrape.cpp: #include "screenscrape.h" usin...

ostream showbase non-present for zero value, and internal doesn't work for HANDLE? Must I fudge it?

PSPS: (a Pre-scripted Post-script) It has just come to mind that a more prescient question would have included the notion of: Is this non-display of "0x"(showbase) for zero-value integers a standard behaviour, or is it just a quirk of my MinGW implementation? It all began on a pleasant Sunday morning... I want to dump some Handles i...

symmetrical associative array search by key and value

I need to describe an associative array in which to search, you can use the key and value. With functions add, delete, getBy1st (search by key), getBy2nd (search by value). For example in C++: symmap<std::string, int> m; m.insert(make_pair<std::string,int> ("hello", 1)); m.insert(make_pair<std::string,int> ("wow", 2)); ... m.getBy1st(...

Call C++ from an assembly bootloader

Hello, I have a small assembly bootloader that I got from this Tutorial. The code for the boot loader can be found here. I want to know if its possible to run c++ from this boot loader. I want to run a simple thing like this: #include <iostream> using namespace std; int main () { cout << "Hello World!\n"; return 0; } But as I can se...

what's bubble sort good at?

Possible Duplicate: What is a bubble sort good for? I'am sure every algorithm has its advantage and disadvantage, so how about buble sort compared to other sorting algorithm? (ofcourse I hope the answer is other than "easy to learn") ...

RAII and assignment

I created the following class for an sqlite3 connection: class SqliteConnection { public: sqlite3* native; SqliteConnection (std::string path){ sqlite3_open_v2 (path.c_str(), &native, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL); } ~SqliteConnection (){ sqlite3_close(native); } } and then one...

how do I validate user input as a double in C++?

How would I check if the input is really a double? double x; while (1) { cout << '>'; if (cin >> x) { // valid number break; } else { // not a valid number cout << "Invalid Input! Please input a numerical value." << endl; } } //do other stuff... The above code infinitely outputs the Inv...

Creating a class with static pointers to explicitly loaded DLL functions

Hello all, I want to have multiple instances of a DLLInterface class but as each object will have pointers to the same DLL functions I want these to be static. The below code doesn't compile. (I do have a reason for needing multiple instances containing the same pointers which the stripped down code below doesn't illustrate.) //Heade...

not enough storage is available to process this command in visual studio 2008

I am trying to write a multi-thread program in visual studio (c++). I get this error message when I increase the number of one active class. Is there any way I can get around this problem? I mean should I change some of the setup or should I do something to my code? ...

Help Understanding these equations?

I asked a question regarding Bi linear transformations and received this answer: From that very page you posted, there's a link to the source code. I'll explain the bilinear transformation in http://www.antigrain.com/__code/include/agg_trans_bilinear.h.html The idea here is to find a transformation of the form: output_x = a * input_x...

Is object orientation bad for embedded systems, and why?

Many embedded engineers use c++, but some argue it's bad because it's "object oriented"? Is it true that being object oriented makes it bad for embedded systems, and if so, why is that really the case? Edit: Here's a quick reference for those who asked: so we prefer people not to use divide ..., malloc ..., or other object ori...

Why does the chip control the language to choose

I've asked the question before what language should I learn for embedded development. Most embedded engineers said c and c++ are a must, but also pointed out that it depends on the chip. Can someone clarify? Is it a compiler issue or what? Do chips come with their own specific compilers (like a c compiler or c++ compiler) and that's wh...