Click here to Skip to main content
15,889,808 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Include issues Pin
gamefreak229129-Mar-09 10:17
gamefreak229129-Mar-09 10:17 
GeneralRe: Include issues Pin
Stuart Dootson29-Mar-09 10:30
professionalStuart Dootson29-Mar-09 10:30 
GeneralRe: Include issues Pin
gamefreak229129-Mar-09 11:02
gamefreak229129-Mar-09 11:02 
GeneralRe: Include issues Pin
Stuart Dootson29-Mar-09 11:37
professionalStuart Dootson29-Mar-09 11:37 
GeneralRe: Include issues Pin
gamefreak229129-Mar-09 12:22
gamefreak229129-Mar-09 12:22 
GeneralRe: Include issues Pin
Stuart Dootson29-Mar-09 12:27
professionalStuart Dootson29-Mar-09 12:27 
GeneralRe: Include issues Pin
gamefreak229129-Mar-09 17:22
gamefreak229129-Mar-09 17:22 
Questionusing Container template class. new to containers help please Pin
Brandon Ramirez28-Mar-09 18:14
Brandon Ramirez28-Mar-09 18:14 
i have started turning this program for a class into a container template class program and i'm having trouble with one part.

Stack *Z = new Stack;

the line above is where i'm having trouble. this line is in my main program and i need to set it up for template but i don't know how to do it for this line i can do templates for everywhere else but because of the * i'm not sure how to handle this one. please any help would be great! thank you!

below is the rest of the code:


#include <iostream><br />
<br />
using namespace std;<br />
<br />
struct Box {<br />
       int data;<br />
       struct Box * next;<br />
       };<br />
template < typename T ><br />
class Stack {<br />
<br />
public:<br />
       Stack();<br />
       ~Stack();<br />
       bool Pop(int &);<br />
       void Push(int);<br />
       bool Empty();<br />
private:<br />
       struct Box * Start;<br />
 };<br />
template <typename t=""><br />
Stack <t>::Stack() { Start=NULL; }<br />
template <typename t=""><br />
Stack <t>::~Stack() {<br />
<br />
       struct Box *p1=Start, *p2;<br />
<br />
       while (p1!=NULL) {<br />
               p2=p1->next;<br />
               delete p1;<br />
               p1=p2;<br />
               }<br />
       }<br />
template <typename t=""><br />
bool Stack <t>::Pop(int &x) {<br />
<br />
       struct Box *p1;<br />
       if (Start==NULL) return false;<br />
<br />
       x=Start->data;<br />
       p1=Start->next;<br />
       delete Start;<br />
       Start=p1;<br />
       return true;<br />
       }<br />
template <typename t=""><br />
void Stack <t>::Push(int x) {<br />
<br />
       struct Box *p1 = new struct Box;<br />
       p1->data = x;<br />
       p1->next = Start;<br />
       Start=p1;<br />
       return;<br />
       }<br />
template <typename t=""><br />
bool Stack <t>::Empty() { if (Start==NULL) return true; else return false; }<br />
<br />
<br />
int main() {<br />
template <typename t=""><br />
Stack X;<br />
int x;<br />
<br />
for (int i=0; i<10; ++i) X.Push(i);<br />
<br />
while(X.Pop(x)) cout << x << endl;<br />
<br />
cout << "-------------------------------" << endl;<br />
<br />
Stack *Z = new Stack;<br />
<br />
for (int i=0; i<10; ++i) (*Z).Push(i);<br />
<br />
while(Z->Pop(x)) cout << x << endl;<br />
<br />
Stack Y[10];<br />
<br />
for (int j=0; j<10; j++) {<br />
<br />
       for (int i=0; i<10; ++i) Y[j].Push(i);<br />
<br />
       while(Y[j].Pop(x)) cout << x << endl;<br />
<br />
       }<br />
<br />
return 0;<br />
<br />
}</typename></t></typename></t></typename></t></typename></t></typename></t></typename></iostream>

AnswerRe: using Container template class. new to containers help please Pin
Garth J Lancaster28-Mar-09 20:09
professionalGarth J Lancaster28-Mar-09 20:09 
GeneralRe: using Container template class. new to containers help please Pin
Stuart Dootson28-Mar-09 22:08
professionalStuart Dootson28-Mar-09 22:08 
GeneralRe: using Container template class. new to containers help please Pin
Garth J Lancaster28-Mar-09 23:03
professionalGarth J Lancaster28-Mar-09 23:03 
GeneralRe: using Container template class. new to containers help please Pin
Brandon Ramirez30-Mar-09 4:54
Brandon Ramirez30-Mar-09 4:54 
Questionthe date-elapsing dialog box for the trial version software Pin
Jonathan M Malowitz28-Mar-09 12:05
Jonathan M Malowitz28-Mar-09 12:05 
AnswerRe: the date-elapsing dialog box for the trial version software Pin
«_Superman_»28-Mar-09 18:09
professional«_Superman_»28-Mar-09 18:09 
QuestionHow to add Vertical and Horizontal scrollbars to a CListBox Pin
V K 228-Mar-09 7:05
V K 228-Mar-09 7:05 
AnswerRe: How to add Vertical and Horizontal scrollbars to a CListBox Pin
Hamid_RT28-Mar-09 9:09
Hamid_RT28-Mar-09 9:09 
Questionc++ code required for this small study program Pin
sexinthecity28-Mar-09 4:00
sexinthecity28-Mar-09 4:00 
AnswerRe: c++ code required for this small study program Pin
CPallini28-Mar-09 4:22
mveCPallini28-Mar-09 4:22 
GeneralRe: c++ code required for this small study program Pin
Garth J Lancaster28-Mar-09 23:08
professionalGarth J Lancaster28-Mar-09 23:08 
RantRe: c++ code required for this small study program Pin
Maximilien28-Mar-09 11:06
Maximilien28-Mar-09 11:06 
AnswerRe: c++ code required for this small study program Pin
Joe Woodbury28-Mar-09 16:02
professionalJoe Woodbury28-Mar-09 16:02 
GeneralRe: c++ code required for this small study program Pin
Code-o-mat28-Mar-09 23:23
Code-o-mat28-Mar-09 23:23 
GeneralRe: c++ code required for this small study program Pin
Eytukan29-Mar-09 4:20
Eytukan29-Mar-09 4:20 
JokeRe: c++ code required for this small study program [modified] Pin
Yusuf29-Mar-09 8:51
Yusuf29-Mar-09 8:51 
GeneralRe: c++ code required for this small study program Pin
Joe Woodbury29-Mar-09 11:52
professionalJoe Woodbury29-Mar-09 11:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.