Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

Jay03

@Jay03
About
Posts
87
Topics
37
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Enumerated types
    J Jay03

    thanks for the ans boys

    C / C++ / MFC help question

  • Enumerated types
    J Jay03

    Hey guys, I was wondering if u can have a user defined type such as: public enum Pizza { SMALL = 5.99, M = 7.99, L = 9.99 }; I am not quite sure if you can declare double variables inside the Pizza type? I believe someone can help :confused:

    C / C++ / MFC help question

  • Finding number of occurences in a list of numbers
    J Jay03

    thanks, thats great i got a bit confused when I first saw your code, but....... it works!!! THANKS !!!!!!! :-D:-D:-D:-D:-D:-D:-D:-D:-D:-D:-D:-D:-D:rose::rose:

    C / C++ / MFC help tutorial

  • Finding number of occurences in a list of numbers
    J Jay03

    hey guys, I was wondering what the most efficient way of finding the number of occurences in a list is. Say I have a list.... struct data{ int number; int occurences; }; data list[7]; list[0].number = 5; list[1].number = 6; list[2].number = 6; list[3].number = 8; list[4].number = 9; list[5].number = 9; list[6].number = 9; how would i sort in such a way that I eliminate the numbers that occur more than once like this, list[0].number = 5; list[1].number = 6; list[2].number = 8; list[3].number = 9; and saves the number of occurence for each number list[0].occurences = 1; list[1].occurences = 2; list[2].occurences = 1; list[3].occurences = 3; I thought of every possible way, I can do it for numbers that appear twice but three times, i duno how to deal with it..... Someone please help me out :doh::doh::doh::doh::doh::doh::confused::confused::confused:

    C / C++ / MFC help tutorial

  • Reading from a file input
    J Jay03

    Hey guys, I am suppose to read in from a text file. M is the sex and 24 is the age. The file I'm currently reading has the following code. I am wondering what the ws is for. I see how fin >> sex is reading in the sex of the person and fin >> swimmer[actualSwimmers].age is reading in the age. What is the >> ws doing there??? Someone please help me out here thanks in advance. M 24 fin >> sex; fin >> swimmers[actualSwimmers].age >> ws;

    C / C++ / MFC question help

  • main parameters.........
    J Jay03

    Hey guys, I was wondering when we use these parameters (int argc, char *argv[]) in a main function? I have no clue why they use it.... Thanks in advance void main (int argc, char *argv[]) { .......... ......... }

    C / C++ / MFC question

  • calling a function two ways
    J Jay03

    it does actually...... does

    take away the preprocessor statements

    C / C++ / MFC question announcement

  • calling a function two ways
    J Jay03

    RTI::AttributeHandleValuePairSet* Ball::createNVPSet()
    {
    RTI::AttributeHandleValuePairSet* pBallAttributes = NULL;

    //! Make sure the RTI Ambassador is set.
    if ( ms_rtiAmb ) // if ms_rtiAmb!=NULL
    {
    pBallAttributes = RTI::AttributeSetFactory::create( 4 );

    pBallAttributes->add( Ball::ms_ballLocationXId,
    (char*)&this->m_currentState.x,
    sizeof(double) );
    pBallAttributes->add( Ball::ms_ballLocationYId,
    (char*)&this->m_currentState.y,
    sizeof(double) );
    pBallAttributes->add( Ball::ms_ballVelocityXId,
    (char*)&this->m_currentState.vx,
    sizeof(double) );
    pBallAttributes->add( Ball::ms_ballVelocityYId,
    (char*)&this->m_currentState.vy,
    sizeof(double) );
    }

    //! pClockAttributes is allocated on the heap and must be
    //! deallocated by the calling function
    return pBallAttributes;
    }

    void Ball::sendUpdate()
    {
    if ( m_nextStateCalculated == RTI::RTI_TRUE )
    {
    m_currentState = m_nextState;
    m_nextStateCalculated = RTI::RTI_FALSE;

    try
    {
    /*!
    * In order to send the values of our attributes, we must
    * construct an AttributeHandleValuePairSet (AHVPS) which
    * is a set comprised of attribute handles, values, and
    * the size of the values.
    */
    RTI::AttributeHandleValuePairSet* pNvpSet = createNVPSet();
    /*!
    * Send the AHVPS to the federation.
    *
    * this call returns an event retraction handle but we
    * don't support event retraction so no need to store it.
    */
    (void) ms_rtiAmb->updateAttributeValues( getInstanceId(),
    *pNvpSet,
    NULL );
    //! Must free the memory
    pNvpSet->empty();
    delete pNvpSet;
    }
    catch ( RTI::Exception& e )
    {
    cerr << "BALL: Error:" << &e << endl;
    }
    }
    }

    void Ball::update(
    RTI::InteractionClassHandle theInteraction,
    const RTI::ParameterHandleValuePairSet& theParameters )
    {
    if (ms_rtiAmb) // if ms_rtiAmb!=NULL
    {
    if ( theInteraction == Ball::ms_clockTickId )
    {
    RTI::ParameterHandle paramHandle;
    RTI::ULong valueLength;

    //! We need to iterate through the AttributeHandleValuePairSet
    //! to extract each AttributeHandleValuePair. Based on the type
    //! specified ( the value returned by getHandle() ) we need to
    //! extract the data frlom the buffer that is returned by
    //! getValue().
    for ( unsigned int i = 0; i < theParameters.size(); i++ )
    {
    paramHandle = theParameters.getHandle( i );
    if ( paramHandle == Ball::ms_clockTickIntervalId )
    {
    double timeInterval = 1 / 60.0;
    theParameters.getValue( i, (char*)&timeInterval, valueLength );

    //! Update all clock objects
    for ( unsigned int j = 0; j < ms_numInstances; j++ )
    {
    ( *( (Ball*)(ms_instances[

    C / C++ / MFC question announcement

  • calling a function two ways
    J Jay03

    RTI::AttributeHandleValuePairSet* Ball::createNVPSet() { RTI::AttributeHandleValuePairSet* pBallAttributes = NULL; //! Make sure the RTI Ambassador is set. if ( ms_rtiAmb ) // if ms_rtiAmb!=NULL { pBallAttributes = RTI::AttributeSetFactory::create( 4 ); pBallAttributes->add( Ball::ms_ballLocationXId, (char*)&this->m_currentState.x, sizeof(double) ); pBallAttributes->add( Ball::ms_ballLocationYId, (char*)&this->m_currentState.y, sizeof(double) ); pBallAttributes->add( Ball::ms_ballVelocityXId, (char*)&this->m_currentState.vx, sizeof(double) ); pBallAttributes->add( Ball::ms_ballVelocityYId, (char*)&this->m_currentState.vy, sizeof(double) ); } //! pClockAttributes is allocated on the heap and must be //! deallocated by the calling function return pBallAttributes; } void Ball::sendUpdate() { if ( m_nextStateCalculated == RTI::RTI_TRUE ) { m_currentState = m_nextState; m_nextStateCalculated = RTI::RTI_FALSE; try { /*! * In order to send the values of our attributes, we must * construct an AttributeHandleValuePairSet (AHVPS) which * is a set comprised of attribute handles, values, and * the size of the values. */ RTI::AttributeHandleValuePairSet* pNvpSet = createNVPSet(); /*! * Send the AHVPS to the federation. * * this call returns an event retraction handle but we * don't support event retraction so no need to store it. */ (void) ms_rtiAmb->updateAttributeValues( getInstanceId(), *pNvpSet, NULL ); //! Must free the memory pNvpSet->empty(); delete pNvpSet; } catch ( RTI::Exception& e ) { cerr << "BALL: Error:" << &e << endl; } } } void Ball::update( RTI::InteractionClassHandle theInteraction, const RTI::ParameterHandleValuePairSet& theParameters ) { if (ms_rtiAmb) // if ms_rtiAmb!=NULL { if ( theInteraction == Ball::ms_clockTickId ) { RTI::ParameterHandle paramHandle; RTI::ULong

    C / C++ / MFC question announcement

  • calling a function two ways
    J Jay03

    Is my initial argument correct now?

    C / C++ / MFC question announcement

  • calling a function two ways
    J Jay03

    sorry im missing some detail. The function createNVPSet is a member of class Ball. PairSet* Ball::CreateNVPSet() { ............ ............ return set; }

    C / C++ / MFC question announcement

  • calling a function two ways
    J Jay03

    sorry im missing some detail. The function createNVPSet is a member of class Ball. PairSet* Ball::CreateNVPSet() { ............ ............ return set; }

    C / C++ / MFC question announcement

  • calling a function two ways
    J Jay03

    Hey guys, I don't see the difference in using two different ways of calling a function. in the function send, you are creating a pair of set by calling the function creatNVPSet(); In the function update, you are creating a pair of set by first creating a pointer to a Ball object and then using the pointer pBall to call upon the member function createNVPSet(); What's the point of doing that? Can both of the function just create the set by using createNVPSet(); instead of using pBall->creatNVPSet(); thanks in advance :) PairSet* CreateNVPSet() { ............ ............ return set; } void send (int x, int y) { PairSet* pNvpSet = createNVPSet(); ................ ............. } void update (int a, int b) { Ball *pBall; PairSet* pNvpSet = pBall->createNVPSet(); ........... ........ }

    C / C++ / MFC question announcement

  • [Message Deleted]
    J Jay03

    [Message Deleted]

    System Admin

  • [Message Deleted]
    J Jay03

    [Message Deleted]

    System Admin

  • Object Definition
    J Jay03

    Zac Howland wrote:

    This syntax is creating a function pointer

    Won't it be typedef void UpdateHandlerPtr (ObjectRootPtr, const RTI::AttributeHandleValuePairSet&); or typedef void (UpdateHandler*) (ObjectRootPtr,const RTI::AttributeHandleValuePairSet&);

    C / C++ / MFC question

  • Object Definition
    J Jay03

    typedef UpdateHandler* UpdateHandlerPtr; I saw this code in a project file but I couldn't find what the definition of UpdateHandler is. It is not defined anywhere. Only thing I found on UpdateHandler is the code below What does the syntax below do? typedef void UpdateHandler(ObjectRootPtr, const RTI::AttributeHandleValuePairSet&);

    C / C++ / MFC question

  • Syntax problems
    J Jay03

    Hey Rage, thanks for the reply What if you had a situation where you had two functions of the same parameters (obj, theAttributes). How does the pointer know which function to point to?

    Rage wrote:

    (*ms_updateHandlers[i]) points on function number i in the array.

    I thought ms_updateHandlers is an array of pointers therefore i is a pointer number Thanks

    C / C++ / MFC help learning

  • Syntax problems
    J Jay03

    void ObjectRoot::runUpdateHandlers( ObjectRootPtr obj, const RTI::AttributeHandleValuePairSet& theAttributes ) { if (obj) { for (unsigned int i=0; i < ObjectRoot::ms_numUpdateHandlers; i++) { if (ObjectRoot::ms_updateHandlers[i]) { (*ms_updateHandlers[i])(obj, theAttributes); } } } } I don't understand what the code highlighted in brown does....... I am a beginner... please help me out Thanks

    C / C++ / MFC help learning

  • Syntax problem
    J Jay03

    Viorel. wrote:

    The ms_instances array contains pointers to Ball objects

    What happens when j = 0; Ball * const ball = ms_instance[0]; Does this mean it has no pointers because ms_instance[0] ? Do you need atleast j = 1 to create a pointer ........ like ms_instance[1] means 1 pointer .... ms_instance[2] means array of two pointers......... so what does 0 mean? ball->m_stateTimeInterval = timeInterval; -------------------------------------------------------------------------------------------- So for each j value, there will be an array of pointers created?

    C / C++ / MFC question help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups