SlideShare a Scribd company logo
1 of 3
Download to read offline
My question is pretty simple, I just want to know how to call my operator== function in
Stack.cpp using a list function.
Here is what I meant. This is my Stack.h file:
class Stack {
public:
/**constructors and destructors*/
Stack();
Stack(const Stack &S);
~Stack();
void pop();
void push(int data);
bool operator==(const Stack &S);
[ .......]
private:
List stack;
};
Here is my List.h file:
template
class List {
private:
struct Node {
listitem data;
Node* next;
Node* previous;
Node(listitem data) :
next(NULL), previous(NULL), data(data) {
}
};
typedef struct Node* NodePtr;
NodePtr start;
NodePtr end;
NodePtr cursor;
int length;
public:
........
bool operator==(const List &list);
[.......] }
[........]
template
bool List::operator==(const List& list) {
if (length != list.length)
return false;
NodePtr temp1 = start;
NodePtr temp2 = list.start;
while (temp1 != NULL) {
if (temp1->data != temp2->data)
return false;
temp1 = temp1->next;
temp2 = temp2->next;
}
return true;
}
[......]
So I already define my functions in List.h and I only need to call my function from List again in
my Stack.cpp file. For example from my Stack.cpp:
Stack::Stack(const Stack &S) :
stack(S.stack) {
}
void Stack::pop() {
stack.remove_start();
}
[......]
And I don't know how to call my operator== function in Stack.cpp from the List.h like the way
above. This is what my guess so far but did not work:
bool Stack::operator==(const Stack &S) {
stack.operator==(S.stack);
}
Thank you
Solution
When we wish to make a comparison, such as in an if statement, we use the double equals sign
(==).
1)bool operator==(const Stack &S); [ .......]
It means whatever the boolean operator it should be belongs to stack or equal to.
2) bool operator==(const List &list);
Likewise link list also compare with the constructor link list.
and constructor need not to call explicitly. it will call itself when program called first.

More Related Content

Similar to My question is pretty simple, I just want to know how to call my ope.pdf

Getting the following errorsError 1 error C2436 {ctor} mem.pdf
Getting the following errorsError 1 error C2436 {ctor}  mem.pdfGetting the following errorsError 1 error C2436 {ctor}  mem.pdf
Getting the following errorsError 1 error C2436 {ctor} mem.pdfherminaherman
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfsales98
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfdhavalbl38
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfmallik3000
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfrajkumarm401
 
I have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfI have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfezzi552
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdfPlease complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdfsupport58
 
Table.java Huffman code frequency tableimport java.io.;im.docx
 Table.java Huffman code frequency tableimport java.io.;im.docx Table.java Huffman code frequency tableimport java.io.;im.docx
Table.java Huffman code frequency tableimport java.io.;im.docxMARRY7
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdfadityastores21
 
Please code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdfPlease code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdffarankureshi
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdfafgt2012
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxshericehewat
 

Similar to My question is pretty simple, I just want to know how to call my ope.pdf (20)

Getting the following errorsError 1 error C2436 {ctor} mem.pdf
Getting the following errorsError 1 error C2436 {ctor}  mem.pdfGetting the following errorsError 1 error C2436 {ctor}  mem.pdf
Getting the following errorsError 1 error C2436 {ctor} mem.pdf
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
 
For each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdfFor each task, submit your source java code file.(1) Objective Im.pdf
For each task, submit your source java code file.(1) Objective Im.pdf
 
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdfPLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
PLEASE MAKE SURE THE PROGRAM IS ASKING FOR INPUT FROM USER TO ADD OR.pdf
 
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdfComplete the provided partial C++ Linked List program. Main.cpp is g.pdf
Complete the provided partial C++ Linked List program. Main.cpp is g.pdf
 
I have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdfI have the following code and I need to know why I am receiving the .pdf
I have the following code and I need to know why I am receiving the .pdf
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdfPlease complete ALL of the �TO DO�s in this code. I am really strugg.pdf
Please complete ALL of the �TO DO�s in this code. I am really strugg.pdf
 
Table.java Huffman code frequency tableimport java.io.;im.docx
 Table.java Huffman code frequency tableimport java.io.;im.docx Table.java Huffman code frequency tableimport java.io.;im.docx
Table.java Huffman code frequency tableimport java.io.;im.docx
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Stack queue
Stack queueStack queue
Stack queue
 
Please code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdfPlease code in C++ and do only the �TO DO�s and all of them. There a.pdf
Please code in C++ and do only the �TO DO�s and all of them. There a.pdf
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
Given the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docxGiven the following ADT definition of a stack to use stack .docx
Given the following ADT definition of a stack to use stack .docx
 

More from jeetumordhani

• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdfjeetumordhani
 
You will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdfYou will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdfjeetumordhani
 
You heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdfYou heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdfjeetumordhani
 
write at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdfwrite at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdfjeetumordhani
 
Why have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdfWhy have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdfjeetumordhani
 
Who writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdfWho writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdfjeetumordhani
 
Which of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdfWhich of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdfjeetumordhani
 
Which of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdfWhich of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdfjeetumordhani
 
Which of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdfWhich of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdfjeetumordhani
 
What tissue type has polarity and is avascular What tissue.pdf
What tissue type has polarity and is avascular  What tissue.pdfWhat tissue type has polarity and is avascular  What tissue.pdf
What tissue type has polarity and is avascular What tissue.pdfjeetumordhani
 
What organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdfWhat organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdfjeetumordhani
 
What is meant by modular software and why is it important How can t.pdf
What is meant by modular software and why is it important  How can t.pdfWhat is meant by modular software and why is it important  How can t.pdf
What is meant by modular software and why is it important How can t.pdfjeetumordhani
 
What are the two major steps in biological classification What .pdf
What are the two major steps in biological classification  What .pdfWhat are the two major steps in biological classification  What .pdf
What are the two major steps in biological classification What .pdfjeetumordhani
 
Tissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdfTissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdfjeetumordhani
 
The members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdfThe members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdfjeetumordhani
 
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdfNetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdfjeetumordhani
 
Please help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdfPlease help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdfjeetumordhani
 
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdfNumerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdfjeetumordhani
 
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdfJava AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdfjeetumordhani
 
Irreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdfIrreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdfjeetumordhani
 

More from jeetumordhani (20)

• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
• Sexual orientation is often framed on a binary-gay OR straight; ho.pdf
 
You will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdfYou will need to develop a system that can track employee informatio.pdf
You will need to develop a system that can track employee informatio.pdf
 
You heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdfYou heated the samples containing your cheek cells. Think carefully .pdf
You heated the samples containing your cheek cells. Think carefully .pdf
 
write at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdfwrite at least 3 virulence factors for staph, strep A, strep B, .pdf
write at least 3 virulence factors for staph, strep A, strep B, .pdf
 
Why have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdfWhy have rodents been spectacularly successful What role do you thi.pdf
Why have rodents been spectacularly successful What role do you thi.pdf
 
Who writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdfWho writes the ethical codeSolutionThe Code of Ethics states .pdf
Who writes the ethical codeSolutionThe Code of Ethics states .pdf
 
Which of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdfWhich of these studies might be analyzed with a correlationThe wh.pdf
Which of these studies might be analyzed with a correlationThe wh.pdf
 
Which of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdfWhich of the following statements about instant messaging is incorre.pdf
Which of the following statements about instant messaging is incorre.pdf
 
Which of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdfWhich of the following is not a property of a normal curve A. Bell .pdf
Which of the following is not a property of a normal curve A. Bell .pdf
 
What tissue type has polarity and is avascular What tissue.pdf
What tissue type has polarity and is avascular  What tissue.pdfWhat tissue type has polarity and is avascular  What tissue.pdf
What tissue type has polarity and is avascular What tissue.pdf
 
What organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdfWhat organizations are involved in Internet2How is this developme.pdf
What organizations are involved in Internet2How is this developme.pdf
 
What is meant by modular software and why is it important How can t.pdf
What is meant by modular software and why is it important  How can t.pdfWhat is meant by modular software and why is it important  How can t.pdf
What is meant by modular software and why is it important How can t.pdf
 
What are the two major steps in biological classification What .pdf
What are the two major steps in biological classification  What .pdfWhat are the two major steps in biological classification  What .pdf
What are the two major steps in biological classification What .pdf
 
Tissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdfTissue transplant rejection is primarily atype I reaction.type I.pdf
Tissue transplant rejection is primarily atype I reaction.type I.pdf
 
The members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdfThe members of the UN peace committee, must choose, from among thems.pdf
The members of the UN peace committee, must choose, from among thems.pdf
 
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdfNetWork Design Question1a.) In writing a letter to a Friend, what .pdf
NetWork Design Question1a.) In writing a letter to a Friend, what .pdf
 
Please help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdfPlease help me with thisLet x denote a single observation of a no.pdf
Please help me with thisLet x denote a single observation of a no.pdf
 
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdfNumerical Methods yi + 1 = y_i + Phi (x_i, y_i, h)  Consider the equ.pdf
Numerical Methods yi + 1 = y_i + Phi (x_i, y_i, h) Consider the equ.pdf
 
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdfJava AssignmentConvert infix to postfix.SolutionTo convert i.pdf
Java AssignmentConvert infix to postfix.SolutionTo convert i.pdf
 
Irreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdfIrreducible polynomials over a field F play a similar, in a certain .pdf
Irreducible polynomials over a field F play a similar, in a certain .pdf
 

Recently uploaded

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 

Recently uploaded (20)

Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 

My question is pretty simple, I just want to know how to call my ope.pdf

  • 1. My question is pretty simple, I just want to know how to call my operator== function in Stack.cpp using a list function. Here is what I meant. This is my Stack.h file: class Stack { public: /**constructors and destructors*/ Stack(); Stack(const Stack &S); ~Stack(); void pop(); void push(int data); bool operator==(const Stack &S); [ .......] private: List stack; }; Here is my List.h file: template class List { private: struct Node { listitem data; Node* next; Node* previous; Node(listitem data) : next(NULL), previous(NULL), data(data) { } }; typedef struct Node* NodePtr; NodePtr start; NodePtr end; NodePtr cursor; int length; public: ........
  • 2. bool operator==(const List &list); [.......] } [........] template bool List::operator==(const List& list) { if (length != list.length) return false; NodePtr temp1 = start; NodePtr temp2 = list.start; while (temp1 != NULL) { if (temp1->data != temp2->data) return false; temp1 = temp1->next; temp2 = temp2->next; } return true; } [......] So I already define my functions in List.h and I only need to call my function from List again in my Stack.cpp file. For example from my Stack.cpp: Stack::Stack(const Stack &S) : stack(S.stack) { } void Stack::pop() { stack.remove_start(); } [......] And I don't know how to call my operator== function in Stack.cpp from the List.h like the way above. This is what my guess so far but did not work: bool Stack::operator==(const Stack &S) { stack.operator==(S.stack); } Thank you Solution
  • 3. When we wish to make a comparison, such as in an if statement, we use the double equals sign (==). 1)bool operator==(const Stack &S); [ .......] It means whatever the boolean operator it should be belongs to stack or equal to. 2) bool operator==(const List &list); Likewise link list also compare with the constructor link list. and constructor need not to call explicitly. it will call itself when program called first.