Question:--
Write a program that read a line of text, changes each uppercase letter to lowercase and places each letter both in a queue and onto a stack.
The program should then verify whether the line of text is a palindrome
Output:
Please enter a line of text
I am A.I
i AM a.i
This is a palindrome
---------------------------------------------------------------------
How do i change the capital letter to smaller letter as above output example??? wat function i should add??
i using fstream function..now..wat should i do to change which i can enter text by my own??
thanks 4 helping..
My answers below:-
#include<iostream>
#include <cstdlib> // For EXIT_FAILURE and EXIT_SUCCESS
#include <fstream>
#include<string>
using namespace std;
const int MAX=50; // initialize max string size of 50 characters
typedef char StackElement; // define StackElement
typedef char QueueElement; // define QueueElement
class Stack
{
public:
Stack(){top=-1;arr[MAX]=0;} // default stack constructor
void push(StackElement & ch); // push function
StackElement topNpop(); // top and pop functions combined
bool empty() const; // empty function
private:
StackElement arr[MAX]; // define char array
int top; // define int top
};
/*******************************************
FUNCTION: push()
DESCRIPTION: Pushes an element onto the stack
PRECONDITION: Waiting for function call
POSTCONTION: New element character on top of stack
*******************************************/
inline void Stack::push(StackElement & ch)
{
if(top<MAX)
{
top++; // increment top
arr[top]=ch; // push onto stack
}
else
{
cout<<"Stack is full.\n"; // display stack is full
}
}
/*******************************************
FUNCTION: topNpop()
DESCRIPTION: Reads and pops top element off the stack
PRECONDIION: Waiting for function call
POSTCONDITION: One element read and removed fromt he stack
RETURN: Top element from stack
********************************************/
inline StackElement Stack::topNpop()
{
if(top>-1)
{
return(arr[top]); // returns top element
top--; // remove froms stack
}
else
{
cout<<"Stack is empty.\n"; // display stack is empty
return(0);
}
}
/*******************************************
FUNCTION: empty()
DESCRIPTION: returns result value if stack is empty
PRECONDITION: result=false
POSTCONDITION: result may be true or remain false
RETURN: result if true or false
********************************************/
inline bool Stack::empty() const
{
bool result=false; // initialize bool as false
if (top==-1)
{
result=true; // if top is -1 return result true
return(result);
}
else
{
return(result); // else return false
}
}
class Queue // Queue class
{
public:
Queue(){front=0, back=0;arr[MAX]=0;} // Queue default constructor
void addq(QueueElement & ch); // define addq
QueueElement frontNremoveq(); // define frontNremove
private:
QueueElement arr[MAX]; // initialize QueueElement array
int front, back; // initialize int front and back
};
/*******************************************
FUNCTION: addq()
DESCRIPTION: adds an element onto the queue
PRECONDITION: Waiting for element to add
POSTCONDITION: New element now on the queue
********************************************/
inline void Queue::addq(QueueElement &ch)
{
if(front!=(back+1)%MAX)
{
arr[back]=ch; // add element to back of queue
back=(back+1)%MAX;
}
else
{
cerr<<"Error Queue is full\n"; // display queue is full
}
}
/*******************************************
FUNCTION: frontNremoveq()
DESCRIPTION: reads and removes front element from queue
PRECONDITION: front pointing to front of queue
POSTCONDITION: front element is returned and then incremented
********************************************/
inline QueueElement Queue::frontNremoveq()
{
if(front!=back)
{
return(arr[front]); // return front element
front++; // remove front element
}
else
{
cout<<"Queue is empty.\n"; // display queue is empty
return(0);
}
}
/***************************MAIN******************************/
int main()
{
Stack S; // initialize stack
Queue Q; // initialize queue
string s;
int i=0; // initialze int 'i'
char string[MAX]; // initialize char string
bool RESULT=false; // initilize bool RESULT to false
ifstream inside ("palindromeinput.txt");
if (! inside.is_open())
{ cout << "Error opening file"; exit (1); }
while (! inside.eof() )
{
inside.getline (string,100);
cout << string << endl;
}
while(string[i]!=NULL)
{
S.push(string[i]); // push chars individually from string to
Q.addq(string[i]); // stack and queue
i++; // next char
}
while(i>0)
{
if(S.topNpop()==Q.frontNremoveq()) // compare each element from
{ // stack and queue
RESULT=true; // if same for all chars return true
}
else
{
RESULT=false; // if not same for any char break and return false
break;
}
i--;
}
if(RESULT==true)
{
cout<<string<<" is a palindrome\n"; // display if true
}
else
{
cout<<string<<" is not a palindrome\n"; // display if false
}
ofstream outside ("palindromeoutput.txt");
if (outside.is_open())
{
outside << string;
outside<< string;
outside.close();
}
return 0;
}How do i change the capital letter to smaller letter as above output example
use tolower() to convert a character to lower-case. It only works on one character, so if you want to convert a whole string to lower case you have to create a loop to iterate each character. Here is a c++ example.
#include <string>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cctype>
using namespace std;
int main()
{
string str = "UPPER-CASE";
transform(str.begin(),str.end(),str.begin(),tolower);
cout << str << endl;
return 0;
}I'm not terribly STL-savvy, what is this error telling me?
//Error E2285 testpp.cpp 11: Could not find a match for 'transform<InputIterator1,InputIterator2,OutputIterator,BinaryOperation>(char *,char *,char *,charT (*)(charT,const locale &))' in function main()
...while I continue searching for an answer on my own...
[edit]Found this :transform
template<class InIt, class OutIt, class Fn1>
OutIt <strong>transform</strong>(InIt first, InIt last, OutIt dest,
Fn1 func);
template<class InIt1, class InIt2, class OutIt,
class Fn2>
OutIt <strong>transform</strong>(InIt1 first1, InIt1 last1,
InIt2 first2, OutIt dest, Fn2 func); The first template function evaluates *(dest + N) = func(*(first + N)) once for each N in the range [0, last - first). It then returns dest + (last - first).The call func(*(first + N)) must not alter *(first + N).
The second template function evaluates *(dest + N) = func(*(first1 + N), *(first2 + N)) once for each N in the range [0, last1 - first1). It then returns dest + (last1 - first1). The call func(*(first1 + N), *(first2 + N)) must not alter either *(first1 + N) or *(first2 + N).[Dani - Here I really miss the fixed fonts! Follow the dinkumware link and note my previous replies as to why. Oh, and font sizes would have been beneficial as well.]
[edit=2] Ahh .
I'm not terribly STL-savvy, what is this error telling me?
...while I continue searching for an answer on my own...//Error E2285 testpp.cpp 11: Could not find a match for 'transform<InputIterator1,InputIterator2,OutputIterator,BinaryOperation>(char *,char *,char *,charT (*)(charT,const locale &))' in function main()
Dev-C++ (gcc) has a compiler bug
use tolower() to convert a character to lower-case. It only works on one character, so if you want to convert a whole string to lower case you have to create a loop to iterate each character. Here is a c++ example.
#include <string> #include <algorithm> #include <iostream> #include <iomanip> #include <cctype> using namespace std; int main() { string str = "UPPER-CASE"; transform(str.begin(),str.end(),str.begin(),tolower); cout << str << endl; return 0; }
this what i have done...
still hv some problems...
1.my output:-Please enter a line of text:
i am not a.i
i am not a.i
This is a palindrome <-----it must be this is not a palindrome(uncorrect answers)
Press any key to continue
2. how to use the touppercase() n tolowercase()combine as below???
I am A.I
i AM a.i
#include<iostream>
#include <cstdlib> // For EXIT_FAILURE and EXIT_SUCCESS
#include <fstream>
#include<string>
#include <algorithm>
#include <iomanip>
#include <cctype>
using namespace std;
const int MAX=50; // initialize max string size of 50 characters
typedef char StackElement; // define StackElement
typedef char QueueElement; // define QueueElement
class Stack
{
public:
Stack(){top=-1;arr[MAX]=0;} // default stack constructor
void push(StackElement & ch); // push function
StackElement topNpop(); // top and pop functions combined
bool empty() const; // empty function
private:
StackElement arr[MAX]; // define char array
int top; // define int top
};
/*******************************************
FUNCTION: push()
DESCRIPTION: Pushes an element onto the stack
PRECONDITION: Waiting for function call
POSTCONTION: New element character on top of stack
*******************************************/
inline void Stack::push(StackElement & ch)
{
if(top<MAX)
{
top++; // increment top
arr[top]=ch; // push onto stack
}
else
{
cout<<"Stack is full.\n"; // display stack is full
}
}
/*******************************************
FUNCTION: topNpop()
DESCRIPTION: Reads and pops top element off the stack
PRECONDIION: Waiting for function call
POSTCONDITION: One element read and removed fromt he stack
RETURN: Top element from stack
********************************************/
inline StackElement Stack::topNpop()
{
if(top>-1)
{
return(arr[top]); // returns top element
top--; // remove froms stack
}
else
{
cout<<"Stack is empty.\n"; // display stack is empty
return(0);
}
}
/*******************************************
FUNCTION: empty()
DESCRIPTION: returns result value if stack is empty
PRECONDITION: result=false
POSTCONDITION: result may be true or remain false
RETURN: result if true or false
********************************************/
inline bool Stack::empty() const
{
bool result=false; // initialize bool as false
if (top==-1)
{
result=true; // if top is -1 return result true
return(result);
}
else
{
return(result); // else return false
}
}
class Queue // Queue class
{
public:
Queue(){front=0, back=0;arr[MAX]=0;} // Queue default constructor
void addq(QueueElement & ch); // define addq
QueueElement frontNremoveq(); // define frontNremove
private:
QueueElement arr[MAX]; // initialize QueueElement array
int front, back; // initialize int front and back
};
/*******************************************
FUNCTION: addq()
DESCRIPTION: adds an element onto the queue
PRECONDITION: Waiting for element to add
POSTCONDITION: New element now on the queue
********************************************/
inline void Queue::addq(QueueElement &ch)
{
if(front!=(back+1)%MAX)
{
arr[back]=ch; // add element to back of queue
back=(back+1)%MAX;
}
else
{
cerr<<"Error Queue is full\n"; // display queue is full
}
}
/*******************************************
FUNCTION: frontNremoveq()
DESCRIPTION: reads and removes front element from queue
PRECONDITION: front pointing to front of queue
POSTCONDITION: front element is returned and then incremented
********************************************/
inline QueueElement Queue::frontNremoveq()
{
if(front!=back)
{
return(arr[front]); // return front element
front++; // remove front element
}
else
{
cout<<"Queue is empty.\n"; // display queue is empty
return(0);
}
}
/***************************MAIN******************************/
int main()
{
Stack S; // initialize stack
Queue Q; // initialize queue
string s ;
int i=0; // initialze int 'i'
char string[MAX]; // initialize char string
bool RESULT=false; // initilize bool RESULT to false
strcpy(string," ");
//transform(s.begin(),s.end(),s.begin(),toupper);
cout << "Please enter a line of text: " << endl;
cin.getline (string,100);
while(string[i]!=NULL)
{
S.push(string[i]); // push chars individually from string to
Q.addq(string[i]); // stack and queue
i++; // next char
}
while(i>0)
{
if(S.topNpop()==Q.frontNremoveq()) // compare each element from
{ // stack and queue
RESULT=true; // if same for all chars return true
}
else
{
RESULT=false; // if not same for any char break and return false
break;
}
i--;
}
if(RESULT==true)
{
cout<<string<<" \nThis is a palindrome\n"; // display if true
}
else
{
cout<<string<<" \nThis is not a palindrome\n"; // display if false
}
cout<<s<<s<<endl;
return 0;
}1. start out by replacing that C-style character array named "string" with a c++ string class and name it something else, such as line. You are writing a c++ program, so use c++ classes whenever possible. Not that it can't be done with C, just that it's more consistent.
2. replace cin.getline() with getline(cin,line)
3. paste that transform line after the getline() in #2 above
After making the above changes your program seems to work ok for the strings I entered.
1. start out by replacing that C-style character array named "string" with a c++ string class and name it something else, such as line. You are writing a c++ program, so use c++ classes whenever possible. Not that it can't be done with C, just that it's more consistent.
2. replace cin.getline() with getline(cin,line)
3. paste that transform line after the getline() in #2 above
After making the above changes your program seems to work ok for the strings I entered.
my program is C++ rite???
mind show me where should i add the transform function??
my program is C++ rite???
Yes, it is.mind show me where should i add the transform function??
I already told you. You can do your own copy/paste, my fingers can't ready your keyboard :eek:
Yes, it is.
I already told you. You can do your own copy/paste, my fingers can't ready your keyboard :eek:
show me at least example..then i can only can do it
how to make stack.h,queue.h,palindrome.cpp seperate files....??
show me at least example..then i can only can do it
Haven't you read your own thread :cry: Or maybe you didn't comprehend what you read. The example is in post #2. I'm not about to rewrite it.how to make stack.h,queue.h,palindrome.cpp seperate files....??
With those filename, they are already separate files, so I don't understand your question.
Haven't you read your own thread :cry: Or maybe you didn't comprehend what you read. The example is in post #2. I'm not about to rewrite it.
With those filename, they are already separate files, so I don't understand your question.
now i combine stack,queue together...i wanna seperate stack to stack.h and queue.h and another for .cpp
can show me how?? from my program...
i hv seperate it..hv many errors
now i combine stack,queue together...i wanna seperate stack to stack.h and queue.h and another for .cpp
can show me how?? from my program... i hv seperate it..hv many errors
What are the errors? Post the code or attach the files.
What are the errors? Post the code or attach the files.
Below are my program i hv done..i still cant solve the problems..
pls help me...with errors i hv below for ur reference..
thanks in advance.....Main.cpp
#include <iostream>
#include <cstdlib> // For EXIT_FAILURE and EXIT_SUCCESS
#include <fstream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cctype>
#include "Queue.h"
#include "Stack.h"
using namespace std;
/***************************MAIN******************************/
int main()
{
Stack S; // initialize stack
Queue Q; // initialize queue
string s;
int i=0; // initialze int 'i'
char string[MAX]; // initialize char string
bool RESULT=false; // initilize bool RESULT to false
strcpy(string," ");
cout << "Please enter a line of text: " << endl;
cin.getline (string,100);
for( int j = 0; j < s.size(); ++j)
{
if(s[j] >= 'A' && s[j] <= 'Z')
s += (s[j] | 32);
else
if(s[j] >= 'a' && s[j] <= 'z')
s += (s[j] & (~32));
else
s += s[j];
}
while(string[i]!=NULL)
{
S.push(string[i]); // push chars individually from string to
Q.addq(string[i]); // stack and queue
i++; // next char
}
while(i>0)
{
if(S.topNpop()==Q.frontNremoveq()) // compare each element from
{ // stack and queue
RESULT=true; // if same for all chars return true
}
else
{
RESULT=false; // if not same for any char break and return false
break;
}
i--;
}
if(RESULT==true)
{
cout<<string<<" \nThis is a palindrome\n"; // display if true
}
else
{
cout<<string<<" \nThis is not a palindrome\n"; // display if false
}
cout<<s<<s<<endl;
return 0;
}
Stack.h
#ifndef _Stack_h
#define _Stack_h
const int MAX=50; // initialize max string size of 50 characters
typedef char StackElement; // define StackElement
class Stack
{
public:
Stack(){top=-1;arr[MAX]=0;} // default stack constructor
void push(StackElement & ch); // push function
StackElement topNpop(); // top and pop functions combined
bool empty() const; // empty function
private:
StackElement arr[MAX]; // define char array
int top; // define int top
};
/*******************************************
FUNCTION: push()
DESCRIPTION: Pushes an element onto the stack
PRECONDITION: Waiting for function call
POSTCONTION: New element character on top of stack
*******************************************/
inline void Stack::push(StackElement & ch)
{
if(top<MAX)
{
top++; // increment top
arr[top]=ch; // push onto stack
}
else
{
cout<<"Stack is full.\n"; // display stack is full
}
}
/*******************************************
FUNCTION: topNpop()
DESCRIPTION: Reads and pops top element off the stack
PRECONDIION: Waiting for function call
POSTCONDITION: One element read and removed fromt he stack
RETURN: Top element from stack
********************************************/
inline StackElement Stack::topNpop()
{
if(top>-1)
{
return(arr[top]); // returns top element
top--; // remove froms stack
}
else
{
cout<<"Stack is empty.\n"; // display stack is empty
return (0);
}
}
/*******************************************
FUNCTION: empty()
DESCRIPTION: returns result value if stack is empty
PRECONDITION: result=false
POSTCONDITION: result may be true or remain false
RETURN: result if true or false
********************************************/
inline bool Stack::empty() const
{
bool result=false; // initialize bool as false
if (top==-1)
{
result=true; // if top is -1 return result true
return(result);
}
else
{
return(result); // else return false
}
}
#endif
Queue.h
#ifndef _Queue_h
#define _Queue_h
const int MAX=50; // initialize max string size of 50 characters
typedef char QueueElement; // define QueueElement
class Queue // Queue class
{
public:
Queue(){front=0, back=0;arr[MAX]=0;} // Queue default constructor
void addq(QueueElement & ch); // define addq
QueueElement frontNremoveq(); // define frontNremove
private:
QueueElement arr[MAX]; // initialize QueueElement array
int front, back; // initialize int front and back
};
/*******************************************
FUNCTION: addq()
DESCRIPTION: adds an element onto the queue
PRECONDITION: Waiting for element to add
POSTCONDITION: New element now on the queue
********************************************/
inline void Queue::addq(QueueElement &ch)
{
if(front!=(back+1)%MAX)
{
arr[back]=ch; // add element to back of queue
back=(back+1)%MAX;
}
else
{
cerr<<"Error Queue is full\n"; // display queue is full
}
}
/*******************************************
FUNCTION: frontNremoveq()
DESCRIPTION: reads and removes front element from queue
PRECONDITION: front pointing to front of queue
POSTCONDITION: front element is returned and then incremented
********************************************/
inline QueueElement Queue::frontNremoveq()
{
if(front!=back)
{
return(arr[front]); // return front element
front++; // remove front element
}
else
{
cout<<"Queue is empty.\n"; // display queue is empty
return(0);
}
}
#endifErrors:
--------------------Configuration: Palindrome - Win32 Debug--------------------
Compiling...
Main.cpp
c:\documents and settings\jason23\desktop\palindrome\queue.h(33) : error C2065: 'cerr' : undeclared identifier
c:\documents and settings\jason23\desktop\palindrome\queue.h(33) : error C2297: '<<' : illegal, right operand has type 'char [21]'
c:\documents and settings\jason23\desktop\palindrome\queue.h(51) : error C2065: 'cout' : undeclared identifier
c:\documents and settings\jason23\desktop\palindrome\queue.h(51) : error C2297: '<<' : illegal, right operand has type 'char [17]'
c:\documents and settings\jason23\desktop\palindrome\stack.h(4) : error C2370: 'MAX' : redefinition; different storage class
c:\documents and settings\jason23\desktop\palindrome\queue.h(4) : see declaration of 'MAX'
c:\documents and settings\jason23\desktop\palindrome\stack.h(34) : error C2297: '<<' : illegal, right operand has type 'char [16]'
c:\documents and settings\jason23\desktop\palindrome\stack.h(56) : error C2297: '<<' : illegal, right operand has type 'char [17]'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(25) : error C2872: 'cout' : ambiguous symbol
c:\documents and settings\jason23\desktop\palindrome\main.cpp(25) : error C2297: '<<' : illegal, right operand has type 'char [30]'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(62) : error C2872: 'cout' : ambiguous symbol
c:\documents and settings\jason23\desktop\palindrome\main.cpp(62) : error C2297: '<<' : illegal, right operand has type 'char [50]'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(66) : error C2872: 'cout' : ambiguous symbol
c:\documents and settings\jason23\desktop\palindrome\main.cpp(66) : error C2297: '<<' : illegal, right operand has type 'char [50]'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2872: 'cout' : ambiguous symbol
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const struct std::_Smanip<_Tm> &)' : could not deduce template argument f
or 'class std::basic_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const struct std::_Fillobj<_E> &)' : could not deduce template argument f
or 'class std::basic_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const class std::basic_string<_E,_Tr,_A> &)' : could not deduce template
argument for 'class std::basic_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const short *)' : could not deduce template argument for 'class std::basi
c_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char)' : could not deduce template argument for 'class std
::basic_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const unsigned char *)' : could not deduce template argument for 'class s
td::basic_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char)' : could not deduce template argument for 'class std::
basic_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const signed char *)' : could not deduce template argument for 'class std
::basic_ostream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,_E)' : could not deduce template argument for 'class std::basic_ostream<_
E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2784: 'class std::basic_ostream<_E,_Tr> &__cdecl std::operator <<(class std::basic_ostream<_E,_Tr> &,const _E *)' : could not deduce template argument for 'class std::basic_o
stream<_E,_Tr> &' from 'int'
c:\documents and settings\jason23\desktop\palindrome\main.cpp(69) : error C2677: binary '<<' : no global operator defined which takes type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acce
ptable conversion)
Error executing cl.exe.
Main.obj - 25 error(s), 0 warning(s)The problem is that the header file doesn't know about namespace std. You can solve this in one of at least three ways:
1. move the line "using names std" before the line "incude queue.h" in the main *.cpp file
2. at the top of queue.h declare classes cout and cerr
using std::cout;
using std::cerr;
// and any others that the header file uses
3. in the queue.h header file expeclitly specify the namespace
std::cerr<<"Error Queue is full\n";The problem is that the header file doesn't know about namespace std. You can solve this in one of at least three ways: 1. move the line "using names std" before the line "incude queue.h" in the main *.cpp file
2. at the top of queue.h declare classes cout and cerr
using std::cout; using std::cerr; // and any others that the header file uses3. in the queue.h header file expeclitly specify the namespace
std::cerr<<"Error Queue is full\n";
1. thanks..i just realize...that the "using names std" before the line "include queue.h" and "include stack.h" in the main *.cpp file
2.using std::cout;
using std::cerr;
// and any others that the header file uses
the above...using std::cout and using std::cerr and std::cerr<<"Error Queue is full\n" there was not function....
i didnt put as u told also no error..
wat is it use?? when will is Error Queue is full will display...
help..again...
3. about const int MAX=50; // initialize max string size of 50 characters i put in main.cpp only...can??? is before #include 'Stack.h'
and #include 'Queue.h' rite??
thanks...4 ur help so far... :cheesy:
2. using std::cout; using std::cerr; // and any others that the header file uses the above...using std::cout and using std::cerr and std::cerr<<"Error Queue is full\n" there was not function.... i didnt put as u told also no error.. wat is it use?? when will is Error Queue is full will display... help..again...
you don't need both "using namespace std:" and "using std::cout" at the same time. one one or the other. Both are ok, but not really needed. A lot of programmers don't like to use "using namespace std;" so they use the other forms illustrated.3. about const int MAX=50; // initialize max string size of 50 characters i put in main.cpp only...can??? is before #include 'Stack.h'
and #include 'Queue.h' rite??
I think it would be better to put that declaration in the *.h that uses it. Current c++ standards allow const like that inside the class itself, but not all compilers support it.
i have been given an assignment about palindromes but i don't no how to do the coding in c++ and using queue adt and stact adt to check if a string ia a palindrome
mmamoratwa..
i just want to know that if have already the codes of palindrome using c++..
please help me if have nay idea of that.
thnk you