First  |  Prev |  Next  |  Last
Pages: 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
Templates: default template argument in a friend class template declaration
It's written in the standard that - "A default template-argument shall not be specified in a friend class template declaration" To understand this I tried to execute an example (copy pasted below) on my dev c++ compiler. I can compiler it without errors. I'm feeling that it's deviating from standard or didn't I und... 31 Mar 2008 20:00
coding style
#include <iostream> using namespace std; int main(){ cout<<"Hello world"<<endl; return 0; } OR #include <iostream> int main(){ std::cout<<"Hello world"<<std::endl; return 0; } I've been told many times that the second option is better coding practice, but I fail to understand why.... 10 Apr 2008 16:55
doubt on non-type template-parameter
Dear All, I'm trying to go thru the non-type template-parameter rules in draft c+ + standard. Here is one example which I tried to execute. #include<iostream> template <int *p> class MyArr { public: MyArr(); }; MyArr::my_print() { std::cout<<"Hello World\n"; } main () { ... 31 Mar 2008 19:20
constexpr and interaction with templates
Hi all. I've been reading the constexpr c++ proposal. The constexpr proposal lets you evaluate expressions at compile-time. I wonder, if it would be possible, as an improvement, to make constexpr parameters able to be used for parameters to templates. This could be useful, since in C++03 you cannot do this today. ... 14 Apr 2008 22:36
Why is the return value of array<T, 0>::data() unspecified?
Martin.YorkAmazon(a)gmail.com (Martin York) wrote (abridged): PS. I don't see how a.data() + a.size() could fail (even if the returned value is just a random pointer). I could see a problem if you tried to de-reference it (but you are not doing that). Some CPUs check pointer values early, when they are lo... 31 Mar 2008 19:20
static asserts for value templates
On Mar 31, 1:43 am, Jerzie.Klench...(a)gmail.com wrote: Hello all, I have the following piece of code: template<int i, int j, int k> void foo() { // rule: i >= j // static_assert(i >= j) // static_assert((i - j) >= 2 * k) } int main() { foo<1,2,3>(); return 0; ... 31 Mar 2008 18:39
I got a strange error message when using fstream!
On 31 mar, 11:31, Wader <WaderC...(a)gmail.com> wrote: #include <fstream> #include <iostream> #include <vector> using namespace std; class MyObj { public: int data; ifstream in; }; typedef std::vector<MyObj> MyObjVector; int main(int arc, char* argv[]) { ... 31 Mar 2008 18:39
Using unique with std::map
Vitaly Perlin ha scritto: On Mar 27, 4:39 pm, Alex Shulgin <alex.shul...(a)gmail.com> wrote: At least, you might want to get rid of `_PairType': such names are reserved for language and standard library use at any level. The rest of the code looks OK, though. I agree that value_type is provided... 31 Mar 2008 18:39
containing an object
Please look at the following lines class A { public: int i; A(int j) { i = j; cout<<endl<<" A's constructor" ; } }; class B { public: int k; A a; B( ) { k = 0; cout<<endl<<" Bs constructor" ; } } ; Now, when I declare an object of B... 31 Mar 2008 19:20
Polymorphism question
Hi, I have the following piece of code: #include <iostream> #include <vector> #include <functional> using namespace std; class Shape { public: virtual void draw(){cout << "Drawing a shhape\n"; }; }; class Triangle : public Shape { public: void draw() { static int counte... 31 Mar 2008 19:20
First  |  Prev |  Next  |  Last
Pages: 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53