473,324 Members | 2,370 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,324 software developers and data experts.

print function not working

Could someone check my code as to why my print function is not
working? Also my pop member function is getting an error in main.
<code>

template<class Type>
void Novice<Type>::Print()
{
while(! IsEmpty())
{
std::cout << topPtr->item;
topPtr = topPtr ->next;
}
}

template<class Type>
void Novice<Type>::Pop(Type &y)
{
if(IsEmpty())
throw EmptyStack();
else
{
Node<Type*tempPtr;
tempPtr = topPtr;
topPtr = topPtr -next;
delete tempPtr;
}

}
// main function

int main()
{
Novice<inta;

a.Pop(); // not working
a.Push(1);
a.Push(2);
a.Push(3);

cout << a.length() << endl;
a.Pop();
cout << a.length() << endl;
a.Print();
}
</code>

The compilation error: 13 H:no matching function for call to
`Novice<int>::Pop()'

Apr 14 '07 #1
5 1675
j_*******@yahoo.com skrev:
Could someone check my code as to why my print function is not
working? Also my pop member function is getting an error in main.
<code>

template<class Type>
void Novice<Type>::Print()
{
while(! IsEmpty())
{
std::cout << topPtr->item;
topPtr = topPtr ->next;
}
Can't see any definition for IsEmpty() in your published code.
}

template<class Type>
void Novice<Type>::Pop(Type &y)
LOOK HERE!-------->>>^^^^^^^^^^^^
{
if(IsEmpty())
throw EmptyStack();
else
{
Node<Type*tempPtr;
tempPtr = topPtr;
topPtr = topPtr -next;
delete tempPtr;
}

}
// main function

int main()
{
Novice<inta;

a.Pop(); // not working
a.Push(1);
a.Push(2);
a.Push(3);

cout << a.length() << endl;
a.Pop();
cout << a.length() << endl;
a.Print();
}
</code>

The compilation error: 13 H:no matching function for call to
`Novice<int>::Pop()'
There is no Novice<int>::Pop(), just as the error message says.

--
OU
Apr 14 '07 #2

The compilation error: 13 H:no matching function for call to
`Novice<int>::Pop()'

There is no Novice<int>::Pop(), just as the error message says.

How do I pass the address of the top node to the calling function?
here is the IsEmpty function.
<code>
template<class Type>
bool Novice<Type>::IsEmpty()
{
return (topPtr == -1);
}
</code>

Apr 14 '07 #3
j_*******@yahoo.com skrev:
The compilation error: 13 H:no matching function for call to
`Novice<int>::Pop()'

There is no Novice<int>::Pop(), just as the error message says.

How do I pass the address of the top node to the calling function?
here is the IsEmpty function.
<code>
template<class Type>
bool Novice<Type>::IsEmpty()
{
return (topPtr == -1);
}
</code>
What do you think will equal -1?

--
OU
Apr 14 '07 #4
It was supposed to be:
<code>

....
return (topPtr == NULL);
</code>

About the pop() function. What do I pass to it to make it work?

Apr 15 '07 #5
j_*******@yahoo.com skrev:
It was supposed to be:
<code>

...
return (topPtr == NULL);
</code>
You should copy and paste code instead.
>
About the pop() function. What do I pass to it to make it work?
Hint:

#include <ostream>
struct s {
int i;
};
void f(s & o) {
o.i = 3;
}
int main() {
s p;
f(p);
std::cout<<p.i<<std::endl;
return 0;
}

--
OU
Apr 15 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Michael Foord | last post by:
Here's a little oddity with 'print' being a reserved word... >>> class thing: pass >>> something = thing() >>> something.print = 3 SyntaxError: invalid syntax >>> print something.__dict__...
0
by: Paco Ferre | last post by:
Hello, I founded some examples of WebControl printing in internet and tryed to have them working for a DataGrid, something not very complicated. I have a page, Page1.aspx with a DataGrid...
2
by: Dean Slindee | last post by:
Anybody written code in VB.NET to: 1) show a print preview window of reports already written and stored in an Access 2002 database; or 2) execute the print of a report stored in an Access 2002...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
5
by: Tony | last post by:
Every 10 seconds I need to search a SQL table for orders to print. The orders are created through WebForms on ASP.NET clients. The orders should not print until 10 minutes before they are due. ...
9
by: Scott M | last post by:
I'm printing a directory of about 500 multi-page tifs to a high speed printer and the spooler process is killing me!!! here is a little code..... Public Function PrintImage(ByVal...
9
by: igotyourdotnet | last post by:
I need to create a print preview page BUT my page I need to print has a grid and in the grid I have 2 or 3 columns that have links I want to hide the columns with the links on my print preview page...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
2
by: Flying Kite | last post by:
Hi All, I want to know how to print chinese characters on Zebra Printer, following code working fine with English string, but it's not working for Chinese string. It shows ASCII characters instead...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.