11 Solved Topics
Remove Filter Hi Guys, I am trying to teach myself templates and I keep getting lost in all these compilation errors. Here is the latest // This is the interface for the base class template<class V, class I =int> class Array{ private: vector<V> myStore; public: Array(); Array(I size); Array(I size, V value); … | |
Hi Guys, I am trying to teach myself templates in C++. My current assignment is to create a matrix class by using vector of vectors. I have got most of it done but my code is crashing when I try to overload the random access operator in my matrix class. … | |
Hello everybody, I am trying to teach my stl and after writing some basic programs I have hit a road block. I have an iterator which I am trying to pass to a function template Here is my function template template <class T> void display(typename vector<T>::iterator start, typename vector<T>::iterator end){ … | |
Hello Everybody, I am on a Ubuntu system and I just came across /dev/random I tried searching for examples of how to use this utility (or file/ or command) to generate a random number but I cannot find anything. Quick note I am trying to generate a random number on … | |
Hi All, First of all let me start by saying I love Daniweb and I try to take time out everyday to answer the questions that are posted in the various forums. But I am often on the move which means I have to follow the chains of messages in … | |
Hello Everybody, I have a small confusion with regards to pointers. Here is some code [CODE] int main() { int *p1 = (int*)malloc(sizeof(int)); *p1 = 10; printf("The number is %d",*(char*)p1); }[/CODE] I run the code and the O/p is 10. My question is, is there no difference in using char … | |
Hello Everybody, I have a small doubt regarding how we can call constructors in a C++ class [CODE]class test { public: test() { cout<<"In test\n"; } }; int main() { test t1; test t2(); // This call does not give compile time error but does not call the constructor cin.get(); … | |
Hello people I have a small doubt in operator overloading I am trying to overload the assignment operator. Here is my code for that [CODE] class rational { int x; int y; public: //All the constructos rational operator= (rational num) { // Why do we need to return a reference … | |
Hello People, I cannot understand how this expression gets evaluated .. 1+~0 From what I know ~ has higher priority . So the expression becomes 1+(~0)= 2 But the answer that I got was 0. I know it is some thing to do with the fact that ~ is right … | |
Hello People... I found this sample code online [code=c ] int main(int argc, char* argv[]) { struct bitfield { signed int a:3; unsigned int b:13; unsigned int c:1; }; struct bitfield bit1={2,14,1}; printf("%d",sizeof(bit1)); return 1; } [/code] I compiled this code on linux with gcc compiler and the output I … | |
Hi All, Today I came across a peculiar piece of code. [code] int main(int argc, char* argv[]) { printf("%lf\n",(0.99-0.90-0.09)); } [/code] According to me the output for this code should be 0, but to my surprise when I ran this code the answer that I got was -0.000. I cannot … |
The End.