object& in turbo c++

Pages: 12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#define DEFAULT_DEQUE_SIZE 2
#define DEFAULT_QUEUE_SIZE 2

#ifndef __QUEUE_H
#include <Queue.h>
#endif	// __QUEUE_H

#ifndef __IOSTREAM_H
#include <iostream.h>
#endif

#include<DBLLIST.h>
#include<Queue.h>



class abc :public  Queue
{
 public:
	int a;
	abc(){}

	abc(int a1)
	{
	 a1=a;
	}

	void print()
	{
	 cout<<a;
	}


};


int main()

{
    DoubleList d;
    Queue q;

  for (int i=0;i<5;i++)
  {
   abc obj(i);
  // q.add (obj);
     q.put(obj);
      //*(new abc(i)));

  }

  for (i=0;i<5;i++)
  {
    cout<<"\n ===="<<q.getItemsInContainer();
    cout<<"\n"<< ( (abc&)q.get()).a;
   //cout<< ((abc&)q.peekAtHead()).print();
  }
    return 0;
}


getitemscontainer returns 5 as expected but then pure virtual function called is beign printed in the output!
Galik, thanks a lot. it worked! The weird message was because the objects were destroyed inthe previous program. I changed it to a statement using 'new' and it worked.

Finally I can get on with my work. Your prompt replies are very much appreciated .

Thanks a lot.
Regards,
Diff.thinkr
Topic archived. No new replies allowed.
Pages: 12