Go Back   The UNIX and Linux Forums > Top Forums > Programming
Search Forums:



Programming Post questions about C, C++, Java, SQL, and other programming languages here.

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-08-2012
Registered User
 

Join Date: Feb 2012
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
c++ code

Dear All,

I know java but I am a newbie in c++ and I am trying to learn ns3 .

could anybody tell me what is going on in this two code snippets? ( these are talking from Chap 7 , ns3 tutorial)



Code:
class MyObject : public Object   {   public:     static TypeId GetTypeId (void)     {       static TypeId tid = TypeId ("MyObject")         .SetParent (Object::GetTypeId ())         .AddConstructor<MyObject> ()         .AddTraceSource ("MyInteger",                          "An integer value to trace.",                          MakeTraceSourceAccessor (&MyObject::m_myInt))         ;       return tid;     }          MyObject () {}     TracedValue<int32_t> m_myInt;   };


Code:
int   main (int argc, char *argv[])   {     Ptr<MyObject> myObject = CreateObject<MyObject> ();     myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback(&IntTrace));        myObject->m_myInt = 1234;   }

your help is HIGHLY appreciated

---------- Post updated at 11:37 PM ---------- Previous update was at 11:32 PM ----------

I will post the code snippets again here .

class MyObject : public Object
{
public:
static TypeId GetTypeId (void)
{
static TypeId tid = TypeId ("MyObject")
.SetParent (Object::GetTypeId ())
.AddConstructor<MyObject> ()
.AddTraceSource ("MyInteger",
"An integer value to trace.",
MakeTraceSourceAccessor (&MyObject::m_myInt))
;
return tid;
}
MyObject () {}
TracedValue<int32_t> m_myInt;
};

void
IntTrace (int32_t oldValue, int32_t newValue)
{
std::cout << "Traced " << oldValue << " to " << newValue << std::endl;
}
Sponsored Links
Reply

Tags
c++, c++ in unix, programmers, programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Block of code replacement in Java source code through Unix script hareeshram Shell Programming and Scripting 2 01-30-2012 10:54 AM
If ‘922’ Code does not exist on ‘03’ Record, ‘901’ Code will be there instead, move ‘03’ R sgoud UNIX for Dummies Questions & Answers 1 06-28-2011 01:55 PM
how i prepare a c++ code(c code) for implementing my own protocol format amitpansuria Programming 1 09-06-2007 11:09 PM



All times are GMT -4. The time now is 12:19 AM.