While making own double ended queue class on templates I've noticed something weird, I've already found a solution but don't know how it is so,
look at code :
#include <cstdlib>
#include <iostream>
#include <deque>
using namespace std;
int main(int argc, char *argv[])
{
deque<float> c ();
//c.push_back(1.0);
system("PAUSE");
return EXIT_SUCCESS;
}
The code above compiles without any problems ( using Dev c++ 4.9.9.2 + windows 7/vista -tested on both).
Next thing we have is commented c.push_back(1.0); when I remove comment I get error :
16 G:\JP III\5.12.2011\w domu\main.cpp request for member `push_back' in `c', which is of non-class type `std::deque<float, std::allocator<float> > ()()' G:\JP III\5.12.2011\w domu\Makefile.win [Build Error] [main.o] Error 1
Everything works fine when i delete brackets () in declaration.
I know that this may be caused because there are many constructors for deque library, but while making my project i have the same error when i have declared only one default constructor. Any one knows why I have to use: myQueue<type> q; instead of: myQueue<type> q(); ?


Sign In
Create Account


Back to top









