473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

add copy constructor to my class

this is my class there is a problem with my copy constructor .. is that correct ??

Expand|Select|Wrap|Line Numbers
  1. struct Node
  2. {
  3.     Type info;
  4.     Node<Type> *next;
  5. };
  6.  
  7. template <class Type>
  8. class Queue
  9. {
  10.     Node<Type> *front;
  11.     Node<Type> *rear;
  12.  
  13. public:
  14.     Queue();
  15.     ~Queue(); 
  16.  
  17.  
  18.  
  19.     void enqueue( const Type & numba);
  20.  
  21.     bool dequeue( Type & numba);
  22.  
  23.     bool peek( Type & numba) const;
  24.  
  25.     bool isEmpty() const
  26.     {
  27.         return front == NULL;
  28.     }
  29.  
  30.     void makeitEmpty();
  31.  
  32.     void print()
  33.     {
  34.         cout << "queue: ";
  35.         Node<Type> *pointer1= front;
  36.         while ( pointer1!= NULL )
  37.         {
  38.             cout << pointer1->info << "->";
  39.             pointer1= pointer1->next;
  40.         }
  41.         cout << "NULL" << endl;
  42.     }
  43.  
  44. };
  45.  
  46. template <class Type> 
  47. Queue <Type>::Queue()
  48.     {
  49.         front = NULL;
  50.     }
  51.  
  52. template <class Type> 
  53. Queue <Type>::~Queue () // destructor 
  54.     makeitEmpty(); 
Nov 15 '12 #1
1 1652
weaknessforcats
9,208 Expert Mod 8TB
Your class does not have a copy constructor. So I don't know what your question is.
Nov 15 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: A | last post by:
Hi, A default copy constructor is created for you when you don't specify one yourself. In such case, the default copy constructor will simply do a bitwise copy for primitives (including...
4
by: Kench | last post by:
Sorry if this becomes a repost. I posted this to comp.lang.c++.moderated 1 hour ago still it does not show up there so posting this here. Hi, Consider class A & B both of which implement a copy...
4
by: away | last post by:
1. When a class defined with a member of pointer type, it's necessary to have a copy constructor and assignment operator. If don't pass objects of such class as value in a function and don't do...
8
by: trying_to_learn | last post by:
Why do we need to explicitly call the copy constructor and the operator = , for base class and member objects in composition? ....book says "You must explicitly call the GameBoard copy-constructor...
14
by: MSR | last post by:
I have a couple of questions. 1. Copy Constructor. class A { private: int a1; double d1; char *ptr;
4
by: Tony Johansson | last post by:
Hello Experts! I have this constructor for class Flight. Flight::Flight(string flight_no, Klocka dep_t, Klocka arr_t) : no(flight_no), dep(dep_t), arr(arr_t) {} Both dep and arr are...
8
by: Jesper | last post by:
Hi, Does the concept "copy constructor" from c++ excist in c#. What is the syntax. best regards Jesper.
8
by: shuisheng | last post by:
Dear All, I am wondering how the default copy constructor of a derived class looks like. Does it look like class B : public A { B(const B& right) : A(right) {}
4
by: john | last post by:
Hey guys, Thank you for your input from the last topic. I tried referencing my c+ + book and googled the topic but i'am still confused a bit. I have another problem with that same code. I was...
13
by: JD | last post by:
Hi, My associate has written a copy constructor for a class. Now I need to add an operator = to the class. Is there a way to do it without change her code (copy constructor) at all? Your help...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.