|
Yes yes
I just changed the code so that the operator =() will get called. Forget to change the operator =() function
|
|
|
|
|
C.P.Rajesh wrote: what is wrong in the below code?
Your operator is defined for a hinstance of the object, not for a pointer, the following code will work
base* bb = new Derived;
Derived ddHelper;
Derived* dd = (ddHelper=bb);
Anyway your design is ugly: overloading the assignemnt operator such a way is misleading.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I didn't understand your reply. My requirement is i need a linked list which stores multiple type of objects in a single list. So i have a data class (a template class) like below
template <class T> class data : public base
{
T myData;
public:
T& getData () {return myData;}
bool putData (const T& aData) {myData = aData; return true;}
// Overloaded operator which takes base class pointer
data<T>* operator= (base* aBase)
{
return (data<T>*)aBase;
}
};
Each node has a base class pointer which stores derived class object. So while retrieving the data from linked list i use this overloaded operator. The advantage is if i use data<wrongdatatype> on left handside of = operation it will give compilation error.
If you have any other suggestion for the problem i will be happy to hear.
modified on Friday, April 18, 2008 4:02 AM
<div class="ForumMod">modified on Friday, April 18, 2008 4:03 AM</div>
|
|
|
|
|
C.P.Rajesh wrote: If you have any other suggestion for the problem i will be happy to hear.
Two suggestions:
(1) Use standard library containers.
(2) Exploit polymorphism (i.e. on a well designed class hierarchy, ususally you haven't to bother about the real nature of the pointer, taht is Base* or Derived* ,instead, you just call methods on it and all will go on fine).
(2.bis) If you really need the exact nature of the pointer, use dynamic_cast .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thank you very much for your suggestion.
I have a doubt in the first one. Is there any standard library container which stores different data types in one list, i mean first object is 'int', second is some user defined and so on?
In the second suggestion by saying 'Exploit polymorphism' i beleve you are talking about run time polymorphism i.e using virtual functions. But i am afraid i can't do that because the base class doesn't know about the object type to do any manipulation. If i make it a template class then i cannot have a base pointer in node to point to any data type.
Thank you once again for your time and effort.
|
|
|
|
|
C.P.Rajesh wrote: Is there any standard library container which stores different data types in one list, i mean first object is 'int', second is some user defined and so on?
No. But you could save yourself the complete container hassle, and focus on the conversion.
Or, you could use STL container with boost::any[^]
Boost is quite renowned for their rigid code review and their focus on well thought out concepts.
Its founder list is a who-is-who of the c++-world.
A number of classes from that web site will be part of the next C++ standard library.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
hi,
I am developing SDI application ,inherits from FomView.
It is required that i have to use TTF font type(which i downloaded from Ineternet) on button in run time.
Thank u....
|
|
|
|
|
You can use of CFont::Create and use of SetFont.
|
|
|
|
|
Mira wey, necesitas poner:
CMyView : public CFormView{
CFont fontButton;
//
};
CMyView::OnInitialUpdate(){
LOGFONT lf;
memset(&lf,0,sizeof(lf));
lf.lfHeight=(int)(33);
lf.lfWeight=FW_BOLD;
strcpy(lf.lfFaceName,"Arial");
m_fontButton.CreateFontIndirect(&lf);
GetDlgItem(IDC_MYBUTTON)->SetFont(&fontButton);
}
|
|
|
|
|
hi..
Thanks for Reply..
But when i try to do the same
but "AkruthiDev1"(ttf font for Hindi)inplace of "Arial"..
the code doesn't work..
In some aticle ,they mention that we have to use EnumFontProc() callback function.
Can u please tell me ,how to use that function.
|
|
|
|
|
nop. You Need Install the Font, copy the file .ttf to C:windows/Fonts or $system$/Fonts
Open ControlPanel->fontS
go to menu File->Install New Font
Choice your file .ttf for intall in windows
|
|
|
|
|
i have a huge folder that has over 200 files.
the format of the file struture os like this
main folder -> 3 sub folders
subfolder1 -> folder1, folder2, folder3 ... foldern
subfolder2 -> folder1, folder2, folder3 ... foldern
subfolder3 -> folder1, folder2, folder3 ... foldern
folder i to n has files
everything together will be some 2 gb of data.
i hope the folder structure is clear
now the requirement is each folder has files and there are headers in each file.
i want to extract the header and show the parameters on the combo box. how do i do that?
|
|
|
|
|
Im not sure do you need to FindFirstFile/FindNextFile? for show files
|
|
|
|
|
If your names are very predictable, how about something like:
...
CString s;
CFile f;
for (i = 0; i < 3; i++)
{
for (j = 0; ; j++)
{
s.Format ("c:\\subfolder%i\\folder%i\\blah.file", i, j);
if (!f.Open (s, ..., CFile::modeRead, ...))
break;
f.Read (stuff);
DoSomething (stuff);
f.Close ();
}
}
?
Check parameters for yourself - I know CFile::Open has not been done correctly.
If your subfolders have more random names, then you're going to have to use FindFirstFile / FindNextFile. It will be a bit harder, but not lots.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
hi ,
In dialog based application i have added one menu bar. this menu working properly before apply the theme. but when i am applying theme to dialog then menu position will be changed and disappeared. y it is happening like this.
have any idea to reposition the menu bar?
or any way to solve this problem?
Regards,
Srinivas
|
|
|
|
|
Actually after 45 hours of endurance test of our application, a crash occured at SaveDC please let me know when the SaveDC fails.
Here the SaveDC is returning 0.
|
|
|
|
|
|
In what cases SaveDc returns 0?
|
|
|
|
|
Did you use of GetLastError for see error information?
|
|
|
|
|
No I didn't use GetLastError(), I will check with it. Thank you for reply Hamid.
|
|
|
|
|
You're welcome,I hope you can find it.
|
|
|
|
|
hello everybody
i have taken as input the wireless packets. it contains a two byte control field. i want to extract bits information from these two byte information. how can i do that.
Like control field has 2 bits of type information and 4 bits of subtype information . i want to extract these pieces of information. can anybody tell me how can i do that. in what data type should i take the bits information.
thanks
|
|
|
|
|
|
Hi,
I have a static CString variable declared in the dll.
static CString strUserName;
After which i make some modification to this CString inside the file. Now, I want to export this value.
However in the .def file of the dll, in EXPORTS i mention only the variable name.
EXPORTS
; Explicit exports can go here
strUserName
But i am getting linker error.
Linking...
AppProject.def: error LNK2001: unresolved external symbol strUserName
Kindly help
Priya Sundar
|
|
|
|
|
Priya_Sundar wrote: static CString strUserName;
Remove the static keyword from declaration. If the varaible is global, then there is no need of static isnt it?
|
|
|
|