News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

GCC 3.4.5 compile error

Started by bean, August 17, 2006, 02:55:58 PM

Previous topic - Next topic

bean

hey guys, i dont know where to put this.i have looked in the gnu gcc compiler site and i went lost.

i have an issue, where i cant seem to compie a very simple tempate class. im using gcc 3.4.5 with mingw.

here is my class:
#ifndef TEST_H
#define TEST_H

template <class T>
class test
{
    // variable
   T *_linkedList;
   unsigned int _count;
   unsigned int _capacity;

    public:
        test()
        {
            _linkedList = new T[10];
            memset(_linkedList, 0, 10);
            _count = 0;
            _capacity = 10;
        }

        virtual ~test()
        {
        }

        unsigned int GetCount()
        {
            return _count;
        }

        T Get(int index)
        {
            if( index >= 0 && index <= _count )
                return _linkedList[index];
            else
               return _linkedList[_count-1];
        }

        void Add(T object)
        {
            if( _count+1 <= _capacity-5 )
                _linkedList[_count++] = object;
        }

    protected:
    private:
};

#endif // TEST_H

and when i come to use it:
test<int> t = test<int>();
   t.Add(0);
   t.Add(1);
   t.Add(2);
   int i = t.Get(1);

i get the "ïnstantiated from here" compile error on line "int i = t.Get(1);". I cant see where i am going wrong.

sorry is this is in the wrong place, but i dont know where to podt it.

thxxx

mandrav

Quotei get the "ïnstantiated from here" compile error on line "int i = t.Get(1);". I cant see where i am going wrong.

sorry is this is in the wrong place, but i dont know where to podt it.

Yes, this is the wrong place and yet you didn't even bother to post the exact error messages...  :?:
Be patient!
This bug will be fixed soon...

thomas

test<int> t = test<int>();
   t.Add(0);
   t.Add(1);
   t.Add(2);
   int i = t.Get(1);

i get the "ïnstantiated from here" compile error on line "int i = t.Get(1);"
I am surprised you get that far at all, since you don't have test::operator() declared in your template. If that is a verbatim copy of your code, it should already fail at test<int> t = test<int>()...
Quite likely, you forgot to put a new in there.

But nevertheless, it does not seem related to Code::Blocks.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

bean

sorry guys. the error was totally miss leading. appearently i was comparing an int with an unisnged int variable.  :(

that was the problem.

sorry for any disturbance.

thx