Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Put variables i...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 44036 of 47926
Post > Topic >>

Put variables into member variables or function variables?

by "tjumail@[EMAIL PROTECTED] " <tjumail@[EMAIL PROTECTED] > Mar 21, 2008 at 01:50 AM

I modify my code into following sample code.
CTest is a class only constructed once when the device power on.
CTest::ExecuteRunState is a function entered  periodically.
Do you think whether it is necessary to put the local variables into
class private members?
Otherwise, each time entering the ExecuteRunState(), those local
variables will be decleared and initionalized one time. It's a waste
of cpu resource.


 class CTest
  {
  public:
    CTest();
    ~CTest();

  private:
     void CTest(const CTest & m_CTest);
     void ExecuteRunState(); //This function will entered periodically
  };


void CTest::ExecuteRunState()
{

	tMV  measurement = 0;
	tMVq quality = 0;
	tMVt timeStamp = 0;

	//Here those three variables will gain the newest values.
	pData->GetNewestValue(&measurement, &quality, &timeStamp);
	CalFreq(&measurement);
}
 




 10 Posts in Topic:
Put variables into member variables or function variables?
"tjumail@[EMAIL PROT  2008-03-21 01:50:28 
Re: Put variables into member variables or function variables?
"Jim Langston"   2008-03-21 02:39:34 
Re: Put variables into member variables or function variables?
Andy Champ <no.way@[EM  2008-03-21 10:28:48 
Re: Put variables into member variables or function variables?
"Jim Langston"   2008-03-21 07:06:00 
Re: Put variables into member variables or function variables?
"tjumail@[EMAIL PROT  2008-03-21 09:12:31 
Re: Put variables into member variables or function variables?
"Jim Langston"   2008-03-22 17:53:05 
Re: Put variables into member variables or function variables?
"tjumail@[EMAIL PROT  2008-03-21 09:15:29 
Re: Put variables into member variables or function variables?
Andy Champ <no.way@[EM  2008-03-21 21:22:18 
Re: Put variables into member variables or function variables?
"Default User"   2008-03-21 22:05:46 
Re: Put variables into member variables or function variables?
"tjumail@[EMAIL PROT  2008-03-23 09:03:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 18:18:49 CDT 2008.