|
Callback function and templates Hi, I want to use a callback function together with templates. Let's say I've this code: File a.h: class A { private: template< typename T > void func( bool( T::*f)(void) ); }; ----------------- File a.cc: template< typename T > void A::func( bool( T::*f)(void) ) { f(); } ----... 7 May 2008 11:35
copy values from Hi, i have to vectors. std::vector<double> a; std::vector<double> b; same type, size and have synchronous value pairs. The values in "a" are decimal time values (linear increasing). Now i want to copy in a 3rd vector "c" all elements from a start value to a end value. My first idea was something like: s... 7 May 2008 04:53
Wanna do a WriteLongwordBits contest ? (Skybuck's SimInt64 C/C++ version) Ok, I ported my simulated-int64-Delphi-2007-version to Visual Studio 2008, to compare assembler outputs, Here is the Visual Studio 2008 C/C++ version and it's output: // *** Begin of C/C++ Code *** #include <stdio.h> #include <windows.h> /* Skybuck's WriteLongword (simulated int64 version) ported t... 6 May 2008 22:24
initialising built in types with curly braces I've just discovered that this is legal in c++. int x={10}; What's the point of allowing this? Is it just to be consistent with the initialisation of structs and arrays? Are these 3 all equivalent then? int x(10); int x =10; int x ={10}; ... 6 May 2008 21:20
char** or char*** in function arguments? Ulrich Eckhardt wrote: Pat wrote: What does it mean when a function argument contains multiple "*" - for example: /***************************************/ int GetNameData(char*** faceName) { *faceNames = registeredFaceNames; return numOffaceNames; } There's nothing special... 6 May 2008 21:20
Allocating memory with "new" I have a question about the new operator. The syntax for it is: int * pointer = new int; which says that "pointer" points to a type int variable. My question is why is "int" needed twice? I know it's needed from a syntax standpoint, but I don't understand what additional information the second int reall... 24 Apr 2008 05:50
Mapping Templates function betweeen 2 class Hi, I need to know how to solve this problem of the code , kindly help me if any one know this given 2 classes A and B defined as follows struct A { int a; } struct B { int b; char c; } the requirement is to efficiently write 2 map classes 1. class AMap It should have member functions... 23 Apr 2008 18:45
Inheriting from built-in types I'd like to create a new type which is polymorphic to int but has some different characteristics, something like this: struct ModuloInt : int { // <-- Note: class derives from int ModuloInt(int Value) : int(Value) {}; }; int main(void) { ModuloInt i = 10; } Neit... 21 Apr 2008 09:06
i need help what is use of pointer,link list,trees.volatile pointer. volatile what purpose use. i need static function,callback,inline example. ... 21 Apr 2008 02:30
throw msg macro I'm trying to define a macro to be able to pass to throw a character constant and some other values Here's what I'm defining #ifndef CR #define CR << "\n" #endif #ifndef FL #define FL << " (" << __FILE__ << ':' << __LINE__ << ")" #endif #ifndef SP #define SP << ' ' #endif #ifndef MSG #define MSG(m) st... 20 Apr 2008 18:35
ostream_iterator In my book there is an example with an ostream_iterator like this: (it should bring a[] on the screen) -------- #include <iostream> #include <algorithm> //#include <ostream> didn't help using namespace std; int main(){ int a[] = {22, 33, 44, 55, 66, 77, 88, 99}; copy(a, a+6, ostream_iterator<int>(cout,... 20 Apr 2008 16:11
initializing array with list Me stupid. Working: int main() { int testarray[] = { 0, 1, 2}; return 0; } Not working: class testclass { public: static const int testarray[] = { 0, 1, 2}; }; int main() { testclass Testobjekt; return 0; } Why is the second example wrong? How should i do that? TIA Chris ... 20 Apr 2008 14:35 |