|
how did u bring those mydata in-side the angular brackets .
and that horizontal slash in prev post.
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
FarPointer wrote: and that horizontal slash in prev post.
Horizontal rule.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
The second link contains a good example. They are using the <vector> class. I am using the <list> class to store my list. I suppose I can use the vector example to implement what I am trying to do with the <list> class. I will have to think about this because I do not think items in lists can be accessed at random like vectors. Perhaps I am wrong on both accounts.
Regards again.
HRW
-- modified at 13:36 Monday 10th July, 2006
|
|
|
|
|
try overiding the < operator of the struct.
Chosing between vector and list you need to be careful bcoz the vector reallocates the whole data on push_back if it doesnt has space to expand ,while list is a linked list .so u need to choose according to your ease.
just bcoz you cant do sort on it doesnt mean we have to drop it , you can also write sort from scratch.
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
Harold,
You'll do much better if you get (1) a copy of Stroustrup and (2) a copy of Josuttis. Read them in that order. Because what you want to do is trivial and will be explained by the first book; putting in the time for the second will be worth it.
earl
|
|
|
|
|
Are these C++ authors of C++ books? I will look for them. I did not see anything in the Deitel & Deitel book that was too helpful.
|
|
|
|
|
Hit up amazon for those two. Stroustrup largely invented C++ and wrote one of the definitive books on it; Josuttis wrote a book on the standard library that is a great complement to the former.
|
|
|
|
|
I did check amazon and saw several books by Stroustrup. Do you know the title of the book?
-- modified at 21:13 Monday 10th July, 2006
|
|
|
|
|
http://www.amazon.com/gp/product/0201700735/sr=8-1/qid=1152627803/ref=pd_bbs_1/002-6564248-4536802?ie=UTF8
http://www.amazon.com/gp/product/0201379260/002-6564248-4536802?n=283155
|
|
|
|
|
Simply define an ordering by implementing operator < . i.e.
struct data
{
string Length;
string Sequence;
string N_Terminal;
string C_Terminal;
friend bool operator<(const data &L, const data &R)
{
return L.Sequence<R.Sequence;
}
};
g_DataList.sort();
Steve
|
|
|
|
|
So after creating the list, doesn't the sort function take in one parameter of type data? And will the list be printed in sorted order after the sort function is invoked?
|
|
|
|
|
The list already knows the type of the data it contains. There are two member functions of list called sort : one with no parameters and one which takes a predicate. I'm using the one which takes no parameters and overloading operator < . Give it a try and see if it works for you.
Steve
|
|
|
|
|
Thanks! This really helps because my goal is to actually compare the string length of the Sequence variable and assign that value to int Number as I have it defined below:
struct data
{
int Number;
string Length;
string Sequence;
string N_Terminal;
string C_Terminal;
friend bool operator<(const data &L, const data &R)
{
return L.number > R.number;
}
};
Then I invoke the sort after the list has been populated with items.
g_DataList.sort();
You will notice I overloaded the > operator instead of the < operator since I need the longest strings to appear first.
The thing I do not quite get is how the compiler knows what const data &L and const data &R are when they are passed by reference in the friend function. I'm not making the connection between the comparison and the sort function? Perhaps I do not understand the sorting algorithym. I confess my lack of programming experience even though I have the program working like a champ at this stage.
Regards,
HRW.
-- modified at 4:40 Tuesday 11th July, 2006
|
|
|
|
|
A friend function is really a global function, not a member function. This would be clearer if the declaration and the definition were separated as is shown below:
struct data
{
int Number;
string Length;
string Sequence;
string N_Terminal;
string C_Terminal;
friend bool operator<(const data &L, const data &R);
};
bool operator<(const data &L, const data &R)
{
return L.number > R.number;
}
In this example the function doesn't even need to be made a friend as it doesn't access any protected or private members. With this modification it looks like this:
struct data
{
int Number;
string Length;
string Sequence;
string N_Terminal;
string C_Terminal;
};
bool operator<(const data &L, const data &R)
{
return L.number > R.number;
}
When the compiler sees a < and one or both of the parameters (the expressions to the left and right of the < ) is a user defined type it looks for a user defined operator< . It chooses from all the candidates by matching the types in the expression it is compiling with the types of the operator.
Steve
|
|
|
|
|
Hey if anyone knows about RTI functions, please tell me
if function ClassInIt is declared to publish a certain object and
function InIt is used to subscribe to a certain object.
static void classInit(<br />
RTI::RTIambassador* rtiAmb );<br />
<br />
<br />
static void Init(RTI::RTIambassador* rtiAmb);
Thanks,
Jay
-- modified at 10:43 Monday 10th July, 2006
|
|
|
|
|
That is implementation specific ... and I don't have the RTI-NG source code to look at.
You'd have to show me the source or documentation for those 2 methods for me to be able to tell you exactly what they do.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) This is for CallInIt
void Ball::classInit( RTI::RTIambassador* rtiAmb )<br />
{<br />
ObjectRoot::ms_rtiAmb = rtiAmb;<br />
ObjectRoot::ms_classIdStr = ms_ballIdStr;<br />
<br />
if ( ms_rtiAmb )
{<br />
ms_classId = ms_rtiAmb->getObjectClassHandle( ms_classIdStr );<br />
ms_ballId = ms_rtiAmb->getObjectClassHandle( ms_ballIdStr );<br />
ms_ballLocationXId = ms_rtiAmb->getAttributeHandle( ms_ballLocationXIdStr, ms_ballId );<br />
ms_ballLocationYId = ms_rtiAmb->getAttributeHandle( ms_ballLocationYIdStr, ms_ballId );<br />
ms_ballVelocityXId = ms_rtiAmb->getAttributeHandle( ms_ballVelocityXIdStr, ms_ballId );<br />
ms_ballVelocityYId = ms_rtiAmb->getAttributeHandle( ms_ballVelocityYIdStr, ms_ballId );<br />
ms_clockTickId = ms_rtiAmb->getInteractionClassHandle( ms_clockTickIdStr );<br />
ms_clockTickNumId = ms_rtiAmb->getParameterHandle( ms_clockTickNumIdStr, ms_clockTickId );<br />
ms_clockTickTimeId = ms_rtiAmb->getParameterHandle( ms_clockTickTimeIdStr, ms_clockTickId );<br />
ms_clockTickIntervalId = ms_rtiAmb->getParameterHandle( ms_clockTickIntervalIdStr, ms_clockTickId );<br />
}<br />
}
This is for InIt
void RoundTable::Init( RTI::RTIambassador* rtiAmb )<br />
{<br />
ms_rtiAmb = rtiAmb;<br />
<br />
if ( ms_rtiAmb )<br />
{<br />
<br />
try<br />
{<br />
ms_tableTypeId = ms_rtiAmb->getObjectClassHandle( ms_tableTypeStr );<br />
ms_radiusTypeId = ms_rtiAmb->getAttributeHandle( ms_radiusTypeStr,<br />
ms_tableTypeId); <br />
ms_coefElastTypeId = ms_rtiAmb->getAttributeHandle( ms_coefElastTypeStr,<br />
ms_tableTypeId);<br />
ms_coefFrictionTypeId = ms_rtiAmb->getAttributeHandle( ms_coefFrictionTypeStr,<br />
ms_tableTypeId);<br />
}<br />
catch(RTI::FederateNotExecutionMember e)<br />
{<br />
cerr<<"RoundTable Exception: "<<__LINE__<<endl; <br />
}<br />
}<br />
}
|
|
|
|
|
Is there any sites or books that I can use to study the RTI syntax and how federates get published when another federate subscribes for it. And also the use of Id's in variables. Im a beginner in this and in need of some serious help. It would be great if you can point me to some books or sites.
Thanks,
Jay
|
|
|
|
|
Sadly, no. RTI-NG is a closed-source proprietary library that you have to purchase licenses to use. Since its purpose is limited to modelling and simulation for government contracts, there isn't much wide-spread knowledge on it.
Some of the companies in the industry offer weeklong courses to discuss working with the varying versions of RTI. You might see if GT will pay for you to attend one.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
RTI is vender specific. Different venders may have different implementations. The contraint to RTI is basically HLA (and IEEE 1516) spec, which is fairly loose. I am not aware of any books about RTI. There are only training materials, which again are verder specific and very top level.
I think what you lack is programming fundamentals and a good understanding of C++ language. Take a C++ book and study it seriously. This preparation effort will be paid back.
Best,
Jun
|
|
|
|
|
Jay,
Given some of your other questions recently, you might do better to start by getting a stong working understanding of C++.
earl
|
|
|
|
|
Hi all,
My app needs to destroy a shortcut on the desktop (located in "AllUsers", running on Windows XP). Since the users are not administrators, I use the following code to connect with a dedicated admin account. The (existing) link to delete is "bcFile".
This code works fine with an administrator account and return with no error for normal users. In the later, the shortcut diseapear from the destop only to reappear when the end user press F5. I personnaly guess for a problem in the quotation marks from wCommand or wParams.
PROCESS_INFORMATION pi;
AnsiString sCommand = "C:\\windows\\system32\\cmd.exe";
int iBuffSize = sCommand.WideCharBufSize();
wchar_t* wCommand = new wchar_t[iBuffSize];
wCommand[0] = 0;
sCommand.WideChar(wCommand, iBuffSize);
AnsiString sParams = " del \"/C \"" + bcFile + "\"\" ";
wchar_t wParams[MAX_PATH + 1];
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sParams.c_str(), -1, wParams, MAX_PATH);
AnsiString sUsername = "masteraccount";
AnsiString sDomain = "production";
AnsiString sPassword = "234l2k3j4";
if (CreateProcessWithLogonW(
static_cast<const wchar_t*>(sUsername.data()),
static_cast<const wchar_t*>(sDomain.data()),
static_cast<const wchar_t*>(sPassword.data()),
LOGON_NETCREDENTIALS_ONLY, wCommand,
wParams, 0, NULL, NULL, NULL, &pi) != 0) {
// Notify the shell for delete operation.
SHChangeNotify(SHCNE_DELETE, SHCNF_PATH, bcFile.c_str(), NULL);
}
else {
CustomErrorHandler(ERR_ABORT, ERR_DEL_SHORTCUT);
}
Any help on this or another way to do the shortcut delete will be appreciated.
-- modified at 8:34 Tuesday 11th July, 2006
|
|
|
|
|
Hi,
Due to the tremedeous replies, I finally worked it out myself.
So forget about the CreateProcess stuff.
I now use "CreateThread", in which I call "LogonUser".
Works fine. Simplier. No dependencies to "cmd.exe".
|
|
|
|
|
I have an SDI application. This SDI application has a Splitter control, which has Pane controls and the pane controls themselves have other child controls. So, there is a hierarchy of controls. Now, If I have the handle of any child control, I want to get the Handle of the SDI application window. Is there any way to achieve this?
GetParent() may work, but I would certainly not know how many GetParent()s I am supposed to call. For Example, if I have the HWND of the PaneControl, I would have to call GetParent() twice. One for the Splitter control and the other for the application Window. Similarly, if I have the handle of the Splitter control, I would have to call GetParent() only once. This is the why I think GetParent() is not such a good idea. Any other options?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
<marquee behavior="alternate" scrollamount="5" scrolldelay="50">![Jig | [Dance]](https://codeproject.global.ssl.fastly.net/script/Forums/Images/jig.gif)
|
|
|
|
|
use AfxGetMainWnd type cast the return window to your derived FrameWnd Class
SaRath.
"Where I am from, there is no plan B. So, take advantage of today becuase tomorrow is not promised. - 50 Cent"
<blink>My Blog | Understanding State Patte
|
|
|
|