First  |  Prev |  Next  |  Last
Pages: 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
operator overloading ==
Hi, I am writing a "vector" class. I know about the STL but I prefer to use this as I use this to create a "matrix" class later. I read that using the inbuilt STL to create a matrix is not the best way to do it. At the moment, the class "vec" looks like this. template <class T> class vec { private: i... 5 Mar 2010 15:03
In C++0x, shall I delete functions instead of making them private?
DeMarcus wrote: Hi, I'm working on a new project using C++0x. Before I have always made disabled functions private, like this. class SomeClass { public: SomeClass() {} private: // Disable copying. SomeClass( const SomeClass& ); SomeClass& operator=( const Som... 5 Mar 2010 21:48
New failing in constructor
Say I have the following classes class A{}; class B{}; class C{}; class X{ A* a; B* b; C* c; public: X() : a(new A), b(new B), c(new C) {} }; Say now new fails while initializing C. Since X is not constructed completely it will not call its destructor and we will have a and b n... 5 Mar 2010 06:07
Conversion to non-scalar type
Suppose I have a template class Vector<t> and I define a child class Indices : public Vector<int> { public: Indices(const Vector<int> &v); .... } Now class StaticVector<int,n> has an operator Vector<int>() method. Why do I get then messages such as "conversion from StaticVector<int, 2> to non-scalar t... 4 Mar 2010 05:34
access violation using std::map::erase
Is there a good reason the following code causes access violation in MSVC6? Using std::map::erase, like: aMap.erase( aMap.rbegin().base() ); #include <string> #include <map> typedef std::string cKey; typedef std::string cElement; typedef std::map< cKey, cElement > cMap; int main(int argc, char* argv[]) {... 4 Mar 2010 19:10
C++0x variadic tuple data members
Using variadic templates I can generalise the declaration of template data members, so that something like this: template <typename T1, typename T2, typename T3> struct FooA { T1 var1; T2 var2; T3 var3; }; can, by the use of std::tuple, become: template <typename ... Types> struct FooB { st... 4 Mar 2010 05:34
In C++0x, shall I delete functions instead of making them private?
Hi, I'm working on a new project using C++0x. Before I have always made disabled functions private, like this. class SomeClass { public: SomeClass() {} private: // Disable copying. SomeClass( const SomeClass& ); SomeClass& operator=( const SomeClass& ); }; Is your recommendation to... 5 Mar 2010 15:03
const string & as function parameter
Hi all, I got a compiler error when using "const string&" as function parameter, while using "const string" results in success. The following is my code: ////////////////////////////////////a.h #include <string> class A { public: //... bool func(const char* c); bool func(const std::string& s); /... 3 Mar 2010 08:25
std::map floating point key
Hi All I've searched for a definitive solution but couldn't find one. So I came here... Can I use a floating point number (either single or double precision) as the key for a map (and it work correctly)? I'm aware of the issues with floating point equality but as the map is doing equivalence (strict weak or... 5 Mar 2010 10:30
Job Interview, Did I Mess Up?
I had a job interview recently and I was asked to write three functions on a sheet of paper. I was given 45 minutes for this task. Function 1. Given a string of characters consisting only of upper and lower case letters, sort the characters in alphabetical order, lower case first (i.e., aAbBcC...) Function 2. ... 11 Mar 2010 20:12
First  |  Prev |  Next  |  Last
Pages: 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47