Consider the following code example class Program { static void Main(string[] args) { StudentInfo stud = new StudentInfo(); stud.Name.FirstName = "zai"; //fails assigns firstname as null stud.name.FirstName = "zai"; //works succesfully } } class NameInfo :ICloneable { private string firstname; public string FirstName { get { return firstname; } set { firstname = value; } } public object Clone() { NameInfo n = new NameInfo(); n.LastName = this.lastname; return n; } } class StudentInfo:ICloneable { public NameInfo name = new NameInfo(); public NameInfo Name { get { if (name != null) return (NameInfo)name.Clone(); else return null; } set { if (value != null) name = (NameInfo)value.Clone(); else name = null; } } public object Clone() { StudentInfo s = new StudentInfo(); s.Name = this.Name; return s; } }
the following statement fails when accessing firstname thru Name property stud.Name.FirstName = "zai";
while the one below is ok stud.name.FirstName = "zai";
why?? if I was not using an IClonable interface both of them work....but im not sure its an IClonable issue... is there any rule that says that we souldnt access inner variables through a property of that object?
fordge
Posts
-
Problem with assignment using properties... maybe because of IClonable interface -
Using Context Free GrammersSuppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
Using Context Free GrammersSuppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
Using Context Free GrammersSuppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
Using Context Free Grammershi Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
Using Context Free Grammershi Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
Using Context Free Grammershi Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
Using Context Free GrammersUsing Context Free Grammers Suppose I want an application which takes a source file and outputs its data members and functions. Supposed to develop into a kind of class view explorer. Regarding parsing the source file .... should i go for using regular expressions rules for this parsing or should i go for a language representation in context free grammer[CFG] and use the CFG rules for parsing or is there any other possible ideas for source file parsing awaiting advice fordge
-
GetActiveWindowIm having a UI with dialogs embedded within other parent dialogs say sub dialogs as tabs of a main dlg I need to do some validation when a current tab is active only so I used
CWnd* pWnd = GetActiveWindow(); if(pWnd == this) { //...do something }
however the GetActiveWindow returns the parent window handle and not the sub Windows handle as pointed by this how do Isolve this?? -
using bind2nd function on mapthankx for that one it worked swell im just into STLs now and most of the adapter tutorials seem to have bind1st operating only on vectors so was just tweaking around with maps n function adaptors i ran into another problem....trying to use the solution above in "transform" suppose i get my data as a space seperated string list say a
vector
of"one 1" "two 2" "tri 3" "for 4" "fiv 5"
and have to parse it into amap<string,string>
i tried using the transform function like belowtypedef std::map MyMap; typedef std::vector MyVector; MyMap::value_type ParsetoMap(string str) { //depending on the blank position string::size_type index = str.find(' '); //split into 2 strings MyMap::value_type MyMapPair; MyMapPair.first = str.substr(0, index); //key MyMapPair.second = str.substr(index+1, (int)str.length()); //data return MyMapPair; } void blah2(MyVector & theVec, MyMap const& theMap) { transform(theVec.begin(), theVec.end(), theMap.begin(), ptr_fun(ParsetoMap)); }
but it doesnt work ???
-
using bind2nd function on mapin this case it may be geekish yes..but i still find it more readable but there may be more generic adapters where it would be better to use something other than that while loop also most of the bind1st n bind2nd articles deal only with vectors and was finding it hard to reproduce the same on maps and sets anyway here is the solution i got from a fellow coder typedef std::map MyMap; bool KeyEquals(MyMap::value_type value, int DataValue) { return value.second == DataValue; } std::string blah(MyMap const& theMap, int thing) { MyMap::const_iterator it = std::find_if(theMap.begin(), theMap.end(), std::bind2nd(std::ptr_fun(KeyEquals), thing)); return (it==theMap.end())?std::string():it->second; }
-
using bind2nd function on mapsuppose i have a map m; if i need to search for the location using the int data im currently doing map::iterator iter; for(iter=m.begin(); iter !=m.end(); iter++) { if(iter->second == 10) break; } can i replace this with something like this iter = find_if(m.begin(),m.end(),bind2nd(KeyEquals(),10)); in which case what would the KeyEquals function object be like???
-
using bind2nd function on mapsuppose i have a map m; if i need to search for the location using the int data im currently doing map::iterator iter; for(iter=m.begin(); iter !=m.end(); iter++) { if(iter->second == 10) break; } can i replace this with something like this iter = find_if(m.begin(),m.end(),bind2nd(KeyEquals(),10)); in which case what would the KeyEquals function object be like???
-
multiple key containers??say i have a data that i should be able to lookup using EITHER a int key or a string key..i repeat EITHER.. what kind of container should i be using
-
stl multiple key containers?say i have a data that i should be able to lookup using EITHER a int key or a string key..i repeat EITHER.. what kind of container should i be using
-
icons of task manager??the windows task manager application tab shows the application name as wellas the icon associated to that application/process. i was making a listup of the applications that were running [task manager clone] this i did by using the enumWindows API along with checks on the style sof the window handles obtained and it is working however dunno how to display the icon associated with a process. any advice!!
-
icons of task manager??the windows task manager application tab shows the application name as wellas the icon associated to that application/process. i was making a listup of the applications that were running [task manager clone] this i did by using the enumWindows API along with checks on the style sof the window handles obtained and it is working however dunno how to display the icon associated with a process. any advice!!
-
LVN_GETDISPINFO Using SendMessageIm trying to get the item details of a CListCtrl m_lst1. Using the foloowing code... only that im not getting any result any suggestions -------------------------//-- char szLabel[256]; NMLVDISPINFO NMLVDispInfo; ZeroMemory(&NMLVDispInfo.item, sizeof(LVITEM)); NMLVDispInfo.hdr.code = LVN_GETDISPINFO; NMLVDispInfo.hdr.hwndFrom = AfxGetMainWnd()->m_hWnd; NMLVDispInfo.hdr.idFrom = AfxGetMainWnd()->GetDlgCtrlID(); NMLVDispInfo.item.iItem = 1; NMLVDispInfo.item.mask = LVIF_DI_SETITEM| LVIF_TEXT; NMLVDispInfo.item.pszText = szLabel; NMLVDispInfo.item.cchTextMax = 255; m_lst1.SendMessage(WM_NOTIFY, (WPARAM)NMLVDispInfo.hdr.hwndFrom, (LPARAM)(LPNMHDR) &NMLVDispInfo); -------------------------//--
-
Virus Scannerwhat u r asking me is to keep a list of the proces names that will needed for differnt AV packages the problem with this is that I dont know what package the end user will be using for all i know he maybe using mcAffee or TrendMicro or some other obscure industrial AV solution so i guess maintaining a list of the different processes is out of question ===========================================//== I found out that in Nortons case the "Smart Scan" option has a list of filetype extensions in them so as the NAV agent is started at startup itself when the OS opens any file the AV agent immdeiately scans files if its extension is in the Smart Scan list so that leasd to a conclusion that its not the Office application that calls the AV to start a scan but the AV itself that does this prior to opening the doc ===========================================//== in which case there may not be any generic way to know which is the current AV package installed??? ===========================================//==
-
Virus Scannerso if instead of Norton AV suppose another AV is installed say mcAfee or TrendMicro in that case also do the docs get scanned before they r opened? can anyone who has used any other AV package comment on such a feature in which case then indeed it should be a feature of office that calls some generic interface so that the installed AV software is invoked coz else shouldnt my opening a file in notepad also trigger the file to be scanned by Norton AV. can anyone who has used any other AV package comment on such a feature??