First  |  Prev |  Next  |  Last
Pages: 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
Why does this compile?
Hi all. Consider the following code: template<class T> class A{ T x_; public: A():x_(0){}; A(T x):x_(xx){}; // Note typo: 'xx' instead of 'x' in argument to // x_() constructor }; int main(int argc, char* argv[]) { A<float> a; //A<float> b(1); // <----... 10 Dec 2007 00:00
Calling Class Constructor from Another Constructor
ashwin wrote: I was trying the following on VC++ 6.0 #include <iostream> struct A { A(int a) { x = a; } A(int a, double b) { A::A(a); y = b; } int x; double y; }; int main() { A a(1,2.4); std::cout<<"x="<<a.x<<std::endl; ... 10 Dec 2007 00:00
The concept of "more specialized" in templates
anubhav.saxena(a)wipro.com writes: I have the following code [Irrelevant parts stripped] template<class T, class U> void Afunc(T t, U u){cout << "4";} // 4 template<class T> void Afunc(T t1, T t2){cout << "5";} // 5 template<class T> void Afunc(T* t1, T* t2){cout << "6";} // 6 template<class T> ... 10 Dec 2007 00:00
Specialization of class templates
The book "C++ templates" mentions in the section 3.3 the following "Similar to the overloading of function templates (see page 15), specializing class templates allows you to optimize implementations for certain types or to fix a misbehavior of certain types for an instantiation of the class template. However, if... 10 Dec 2007 00:00
Template inner class problem
template<typename T> class Stack { struct Link { T* data; Link* next; Link(T* dat, Link* nxt) : data(dat), next(nxt) {} }* head; public: Stack() : head(0) {} ~Stack(); void push(T* dat) { head = new Link(dat, head); } T* peek() const { return head ? head->data : 0;... 10 Dec 2007 00:00
typedef of a template specialization
On 27 Nov., 22:49, "Daniel Kr�gler" <daniel.krueg...(a)googlemail.com> wrote: class My { class Impl; std::vector<Impl> pimpl_v; // Warning: U.B.! std::auto_ptr<Impl> pimpl_a; // Warning: U.B.! std::shared_ptr<Impl> pimpl_s; // OK! - Next time... Here I forgot the following member declaratio... 10 Dec 2007 00:00
Deriving from or wrapping basic_string?
On Nov 27, 2:37 pm, Sean Hunt <ride...(a)gmail.com> wrote: [snip] I want an instantiation of basic_string to go with it. However, there is some additional functionality that I'd like. [snip] What's the best way to do this? Is derivation the best way? Or should I use a wrapper class? The latter is safer (es... 10 Dec 2007 00:00
Class template member specialization
Hi, While reading templates, I understood that it is possible to specialize only the relevant member functions of the class template, instead of the specializing the entire template. This is beneficial when the code for most of the member functions is similar. Hence I tried the following sample code. templa... 10 Dec 2007 00:00
auto_ptr definition
On Nov 26, 5:09 pm, Nagrik <vnag...(a)gmail.com> wrote: Hello group, I came across this definition of auto_ptr at Wikipedia. The auto_ptr class is declared in ISO/IEC 14882, section 20.4.5 as: <snip> I am confused about the syntex of third constructor in this definition /***** te... 10 Dec 2007 00:00
Fast argument passing
> I'm seeking comments about this solution, especially about the heuristic (if someone has an experience on a system where the heuristic would not work at all for example) though any suggestion / correcting is welcome. If I read you correctly, this has been developed before: http://www.boost.org/libs/ut... 26 Nov 2007 08:00
First  |  Prev |  Next  |  Last
Pages: 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95