Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3241986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:15:44+00:00 2026-05-17T18:15:44+00:00

I wana define a simple function in my program so I added this prototype

  • 0

I wana define a simple function in my program so I added this prototype in .h file:

      double TimeCalculation (Ptr <Node> mynode,Ptr <Node> nb_node, Ptr <Ipv4> nbipv4, Ptr <Ipv4> myipv4 );

then i wrote this function:

    double
    TimeCalculation (Ptr <Node> mynode, Ptr <Node> nb_node, Ptr <Ipv4> nbipv4, Ptr <Ipv4> myipv4)
    {
                float cpx,expx,myexpx;
                float cpy,expy,myexpy;
                float cpz,expz,myexpz;
                Vector3D cPosition;
                double itspeed;
    /////////// finding current position and exposition for my current neighbor
                cPosition = nbipv4->GetObject<MobilityModel> ()->GetPosition ();
                cpx = nbipv4->GetObject<MobilityModel> ()->GetPosition ().x;
                cpy = nbipv4->GetObject<MobilityModel> ()->GetPosition ().y;
                cpz = nbipv4->GetObject<MobilityModel> ()->GetPosition ().z;
                expx = nb_node->exPosition.at(0);
                expy = nb_node->exPosition.at(1);
                expz = nb_node->exPosition.at(2);
                itspeed = nbipv4->GetObject<ConstantSpeedPropagationDelayModel> ()->GetSpeed ();
                Vector3D normit(0.0,0.0,0.0),mycPosition;
               //Ptr <Node> mynode;
               // Ptr <Node> nb_node;  
                //v1
                //Vector myexposition = Ipv4->GetObject<Node> ()->GetmyPosition ();
                float normitx= cpx - expx;
                float normity= cpy - expy;
                float normitz= cpz - expz; 
                float itVnorm = sqrt((normitx * normitx) + (normity * normity)+(normitz * normitz)); 

                //hamide:update the amount of exposition to current position
                //pos.insert( it2 ,cPosition); 
                nb_node->exPosition.at(0) = cPosition.x;
                nb_node->exPosition.at(1) = cPosition.y;
                nb_node->exPosition.at(2) = cPosition.z;
                //for calculating v2
                //finding exposition for my node which is calculating MPR set
                myexpx = mynode->exPosition.at(0);
                myexpy = mynode->exPosition.at(1);
                myexpz = mynode->exPosition.at(2);
                mycPosition.x = myipv4->GetObject<MobilityModel> ()->GetPosition ().x; 
                mycPosition.y = myipv4->GetObject<MobilityModel> ()->GetPosition ().y; 
                mycPosition.z = myipv4->GetObject<MobilityModel> ()->GetPosition ().z; 
                double mycpx = myipv4->GetObject<MobilityModel> ()->GetPosition ().x;
                double mycpy = myipv4->GetObject<MobilityModel> ()->GetPosition ().y;
                double mycpz = myipv4->GetObject<MobilityModel> ()->GetPosition ().z;         
                //Vector norm(0.0,0.0,0.0);
                double normx= mycpx - myexpx;
                double normy= mycpy - myexpy;
                double normz= mycpz - myexpz;
                //myexPosition.at(1) = mycPosition.at(1);
                //myexPosition.at(2) = mycPosition.at(2);
                //myexPosition.at(3) = mycPosition.at(3); 
                mynode->exPosition.at(0) = mycPosition.x;
                mynode->exPosition.at(1) = mycPosition.y;
                mynode->exPosition.at(2) = mycPosition.z;          
                double myVnorm = sqrt((normx * normx)+(normy * normy)+(normz * normz));

                //v1*v2
                float entmulti = ((normitx * normx) + (normity * normy) + (normitz * normz));
                // calculating cos for the angel between two vectors for two nodes
                float cos = (entmulti /(itVnorm * myVnorm));
                //the maximum distance a node can see its neighbor its based on the 
                //settings we choose for our topology and simulation condition
                int R = 220;
                //v is the speed of each node
                double myspeed = myipv4->GetObject<ConstantSpeedPropagationDelayModel> ()->GetSpeed ();

                double Td = (R * R)/((myspeed *myspeed)+(itspeed * itspeed)-(2 * itspeed * myspeed*cos));
                return sqrt(Td);

    }

but when i run my program It has this error:

debug/libns3.so: undefined reference to `ns3::olsr::RoutingProtocol::TimeCalculation(ns3::Ptr<ns3::Node>, ns3::Ptr<ns3::Node>, ns3::Ptr<ns3::Ipv4>, ns3::Ptr<ns3::Ipv4>)'
collect2: ld returned 1 exit status

and also IT has a problem which it doesn’t work perfect, I will be totally thankful if someone help me with this error and also if u find any other problem in my code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:15:44+00:00Added an answer on May 17, 2026 at 6:15 pm

    In general, you cannot define function-template bodies in source files if you want them to be used by other source files. The compiler needs to be able to see the template definition in order to instantiate the code.

    The solution is to define the function-template body in the header file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wana develop a multi-player chess using c# but I don't have any idea
hi all i wana ask a question about crystal reporting in vs 2008 lets
i have made a urdu editor using swing in java and now wana add
I'm a beginner programmmer, this is for xcode - iPhone. although i made alot
I got this from Java™ I/O, 2nd Edition By Elliotte Rusty Harold :- it
I wana to call a web page and don't need response from page. just
I wana know if we can make a partial specialized class as a friend
I have the following strings in a text file test Table Name.type Market Drinks.tea
What i wana do is actually process some data then insert the processed data
I am required to generate a Pivot table in MS Excel(not in Open Office)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.