| | |
what is going on in this function?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2005
Posts: 61
Reputation:
Solved Threads: 0
Hi guys ,
i am very new to this language so can you tell me which style below function is showing in C++.
i am very new to this language so can you tell me which style below function is showing in C++.
C++ Syntax (Toggle Plain Text)
SmeConfigRnc::SmeConfigRnc(uint32_t rncId, uint16_t pc) : m_RncId(rncId), m_Pc(pc) { //Allocate userId m_UserId = SmeConfigMgr::GetInstance()->GetFromFreeUserIdPool(); printf("Allocated for RNC, User Id=%d\n", m_UserId); //Allocate mtpSap m_MtpSapId = SmeConfigMgr::GetInstance()->GetFromFreeMtpSapIdPool(); printf("Allocated for RNC, MTP SAP=%d\n", m_MtpSapId); }
I'm not sure exactly what you're asking when you say
"can you tell me which style below function is showing in C++"
But I can answer the question in the topic title
"what is going on in this function?"
This line:
Is the constructor for a class called SmeConfigRnc.
The two parameters (rncId and pc) look as though they are user defined types (uint32_t and uint16_t) which are probably defined elsewhere using typedef statements.. (Otherwise they could be primitive types specific to the compiler being used to compile the program!)
Either way it looks as if they are a 32 bit unsigned integer and a 16 bit unsigned integer.
In the part of the constructor code which says:
Two member variables ( m_RncId and m_Pc) are assigned the values passed into the constructor (i.e. the values of rncId and pc respectively)
The first line in the constructors body (after the comment):
This line is doing quite a lot.
SmeConfigMgr looks like it's probably a singleton (a class which can only have one instance in memory), the GetInstance() function will be a static member function of the SmeConfigMgr class which will return a pointer to the current instance of the SmeConfigMgr class.
Basically this line gets a pointer to the SmeConfigMgr class and then calls the GetFromFreeUserIdPool() method of SmeConfigMgr (which I assume returns some kind of int). m_UserId is then assigned the value returned by the call to SmeConfigMgr::GetFromFreeUserIdPool()
The printf statement (which is poor practice to use in a c++ app, std::cout should really be used!) prints a message to the console and shows the value of m_UserId.
Similarly:
This time a pointer to the current instance of SmeConfigMgr is obtained using a call to SmeConfigMgr::GetInstance() and then the GetFromFreeMtpSapIdPool() method of SmeConfigMgr is called.
m_MtpSapId is assigned the value returned by the call to GetFromFreeMtpSapIdPool()
Finally a printf is used to print a message and the value of m_MtpSapId to the console.
I hope that is of some help!
Cheers for now,
Jason.
"can you tell me which style below function is showing in C++"
But I can answer the question in the topic title
"what is going on in this function?"
C++ Syntax (Toggle Plain Text)
SmeConfigRnc::SmeConfigRnc(uint32_t rncId, uint16_t pc) : m_RncId(rncId), m_Pc(pc) { //Allocate userId m_UserId = SmeConfigMgr::GetInstance()->GetFromFreeUserIdPool(); printf("Allocated for RNC, User Id=%d\n", m_UserId); //Allocate mtpSap m_MtpSapId = SmeConfigMgr::GetInstance()->GetFromFreeMtpSapIdPool(); printf("Allocated for RNC, MTP SAP=%d\n", m_MtpSapId); }
This line:
C++ Syntax (Toggle Plain Text)
SmeConfigRnc::SmeConfigRnc(uint32_t rncId, uint16_t pc) : m_RncId(rncId), m_Pc(pc)
The two parameters (rncId and pc) look as though they are user defined types (uint32_t and uint16_t) which are probably defined elsewhere using typedef statements.. (Otherwise they could be primitive types specific to the compiler being used to compile the program!)
Either way it looks as if they are a 32 bit unsigned integer and a 16 bit unsigned integer.
In the part of the constructor code which says:
C++ Syntax (Toggle Plain Text)
: m_RncId(rncId), m_Pc(pc)
The first line in the constructors body (after the comment):
C++ Syntax (Toggle Plain Text)
m_UserId = SmeConfigMgr::GetInstance()->GetFromFreeUserIdPool();
SmeConfigMgr looks like it's probably a singleton (a class which can only have one instance in memory), the GetInstance() function will be a static member function of the SmeConfigMgr class which will return a pointer to the current instance of the SmeConfigMgr class.
Basically this line gets a pointer to the SmeConfigMgr class and then calls the GetFromFreeUserIdPool() method of SmeConfigMgr (which I assume returns some kind of int). m_UserId is then assigned the value returned by the call to SmeConfigMgr::GetFromFreeUserIdPool()
The printf statement (which is poor practice to use in a c++ app, std::cout should really be used!) prints a message to the console and shows the value of m_UserId.
Similarly:
C++ Syntax (Toggle Plain Text)
m_MtpSapId = SmeConfigMgr::GetInstance()->GetFromFreeMtpSapIdPool(); printf("Allocated for RNC, MTP SAP=%d\n", m_MtpSapId);
This time a pointer to the current instance of SmeConfigMgr is obtained using a call to SmeConfigMgr::GetInstance() and then the GetFromFreeMtpSapIdPool() method of SmeConfigMgr is called.
m_MtpSapId is assigned the value returned by the call to GetFromFreeMtpSapIdPool()
Finally a printf is used to print a message and the value of m_MtpSapId to the console.
I hope that is of some help!
Cheers for now,
Jason.
There are 10 types of people in this world.....
Those who understand binary .....
And those who don't!
Those who understand binary .....
And those who don't!
![]() |
Similar Threads
- Need help on a program (function bug) (C)
- Assign content to a function pointer (C)
- PHP Feezing with a function (PHP)
- ASP Replace Function.... (ASP)
- missing function header (C++)
- Function that returns void (C++)
Other Threads in the C++ Forum
- Previous Thread: for and while HELP
- Next Thread: Memory Access Violation
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





