|
KOOOSHA wrote: i hv a stack ADT program. I hv to use it to implement a queue..
Not possible, technically. A queue is a FIFO data structure whereas a stack is a LIFO data structure. Since both of these are linked lists, however, it should be easy enough to implement. Consider:
class list
{
};
class queue : public list
{
};
class stack : public list
{
};
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi all,
In my MDI application, I've written some code for print stuff [in OnPreparePrinting(..)]. It is just a single page document with max. 20 lines of text. It works fine with Laser printer. But I am getting more space between each line in Dot Matrix printer. Where am I wrong?
I am new to MFC Printing. If anyone could suggest me something, it would be more helpful.
Thanks in advance,
Sarvan AL
|
|
|
|
|
I have coded a simple program, as follows:
#include < string >
#include < vector >
using namespace std;
void main ()
{
string word;
vector < string > text;
}
When it is compiled,there are 4 warnings, and I can't solve them, what's wrong?
the warnings are:
D:\C learning\trytry\bbb.cpp(32) : warning C4786: 'std::reverse_iterator,std::allocator > const *,std::basic_string,std::allocator >,std::basic_stringar_traits,std::allocator > const &,std::basic_string,std::allocator > const *,int>' : identifier was truncated to '255' characters in the debug information
D:\C learning\trytry\bbb.cpp(32) : warning C4786: 'std::reverse_iterator,std::allocator > *,std::basic_string,std::allocator >,std::basic_stringits,std::allocator > &,std::basic_string,std::allocator > *,int>' : identifier was truncated to '255' characters in the debug information
d:\program files\microsoft visual studio\vc98\include\vector(39) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > >
>::vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information
d:\program files\microsoft visual studio\vc98\include\vector(60) : warning C4786: 'std::vector,std::allocator >,std::allocator,std::allocator > >
>::~vector,std::allocator >,std::allocator,std::allocator > > >' : identifier was truncated to '255' characters in the debug information
-- modified at 4:33 Thursday 6th April, 2006
|
|
|
|
|
there's no problem about this...
they are warnings, not errors.
compile in release mode and they won't appear anymore.
|
|
|
|
|
Thanks a lot!
and indeed there is another question:
void main ()
{
string word;
vector < string > text;
while ( cin >> word)
{
text.push_back( word );
}
cout << "words read are: \n";
for ( int ix = 0; ix < text.size(); ++ix)
{
cout << text[ ix ] << ' ';
}
cout << endl;
}
when run it, I should input the words into the " string word " from the keyboard, but how to terminate the input?
how to set ( cin >> word) " false " ?
-- modified at 4:53 Thursday 6th April, 2006
|
|
|
|
|
Ctrl + C
otherwise, you'll have to enter a particuliar string on the input stream, and test if the user input equals to the exiting string/condition...
|
|
|
|
|
Another option to disable these warnings (they are irrelevant) is to go in the properties of your project and there (in the C/C++ tab) you should be able to disable them.
|
|
|
|
|
this also works from code :
#pragma warning(disable : 4786)
|
|
|
|
|
Yes but the problem there is that the warning is coming from the STL itself, so, you have to put this pragma in each file you are dealing with vectors, strings, ...
Quite annoying, so it is easier to simply disable them in the properties of your project.
|
|
|
|
|
what about stdafx.h ?
|
|
|
|
|
Yes, but what if you don't use precompiled headers ?
Anyway, both solutions are correct
|
|
|
|
|
I always use a "stdstl.h" header that includes all the STL/Boost files I need, with the necessary pragmas to disable the warnings.
|
|
|
|
|
even precompiled headers are disabled, you can always provide the header, can't you ?
|
|
|
|
|
Cedric Moonen wrote: you should be able to disable them
This depends on the version of VC. In VC++ 6, even with SPs, there is a bug that does not make it possible to remove these warnings.
~RaGE();
|
|
|
|
|
I'd guess you’re using MSVC6. The debug format used with this version was designed before templates became so popular and can't cope with the long symbol names generated when templates are used. You can suppress then using #pragma warning(disable : 4786) . I usually put it in my "stdafx.h" file.
Steve
|
|
|
|
|
Hi,
i have just started learning Vc++. can any one help me with my problem.
i want to insert,delete an item to list box control how to do that?? and to insert folder name in list box? and also i want to access the each item(folder name).
please can anyone help me....
|
|
|
|
|
|
maybe it is some helpful to you
SetCurrentDirectory("c:\\");
m_List2.Dir(DDL_DIRECTORY|DDL_EXCLUSIVE, _T("*.*"));
//example
m_List2.DeleteString(0);
m_List2.AddString("Welcome");
m_List2.InsertString(0,"Hi");
|
|
|
|
|
Hi,
i just added addstring code to project for add button but i am getting the below error.
////code/////
void CUpdateDlg::OnAdd()
{
m_LIST.AddString("Welcome");
}
/////////////
Error:-
Compiling...
UpdateDlg.cpp
D:\Parichay\DesktopSearch\UpdateDlg.cpp(63) : error C2039: 'AddString' : is not a member of 'CString'
c:\program files\microsoft visual studio\vc98\mfc\include\afx.h(368) : see declaration of 'CString'
Error executing cl.exe.
DesktopSearch.exe - 1 error(s), 0 warning(s)
Regards,
Parichay B.P
|
|
|
|
|
m_List seems to be a CString object, not a list !!!
how do you declare it ??
|
|
|
|
|
i just created member variable for IDC_LIST (list box) using MFC class wizard.
there i declared m_LIST of type CString.
i have just started with vc+ i have no idea how these things works.
can u plz help me in adding items to list box and deleting item from list box.
|
|
|
|
|
AddString() is not a member of the CString[^] class.
what did you want to do with this ?
if IDC_LIST is a CListBox, it doesn't have any sense to associate it to a CString variable !!!
explain you wished algorithm for that OnAdd() method please...
|
|
|
|
|
The problem is i have created a list box with add , remove button & edit box.
during the execution of the program i want the contents of the edit box to be added to list box when i click on add button.
so tell me hw to start working with list box and declaring member variables for list box..
where and which function in my program i have use.
|
|
|
|
|
the list is a list (CListCtrl), and the edit stays an edit (CEdit).
what you have to do is :
1. read the edit
2. add to the list
CString strCaption;
m_Edit.GetWindowText(strCaption);
m_List.AddString(strCaption);
do you understand it better now ?
|
|
|
|
|
can u plz tell how to remove the item using the remove button and reset the list
|
|
|
|