Click here to Skip to main content
15,851,243 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: LoadInstanceString failed in Windows7 Operating System. Pin
Richard MacCutchan7-Jun-11 1:21
mveRichard MacCutchan7-Jun-11 1:21 
GeneralRe: LoadString failed in Windows7 Operating System. [modified] Pin
janaswamy uday7-Jun-11 1:42
janaswamy uday7-Jun-11 1:42 
GeneralRe: LoadString failed in Windows7 Operating System. Pin
giangian7-Jun-11 1:50
giangian7-Jun-11 1:50 
GeneralRe: LoadString failed in Windows7 Operating System. Pin
janaswamy uday7-Jun-11 1:57
janaswamy uday7-Jun-11 1:57 
QuestionRe: LoadString failed in Windows7 Operating System. Pin
David Crow7-Jun-11 3:52
David Crow7-Jun-11 3:52 
GeneralRe: LoadString failed in Windows7 Operating System. Pin
Richard MacCutchan7-Jun-11 1:57
mveRichard MacCutchan7-Jun-11 1:57 
GeneralRe: LoadString failed in Windows7 Operating System. Pin
Richard MacCutchan7-Jun-11 1:59
mveRichard MacCutchan7-Jun-11 1:59 
QuestionC++ Question Pin
Software20076-Jun-11 18:18
Software20076-Jun-11 18:18 
I saw the following question as an interview question on one of the sites, Can anyone see if I answered correctly? Thanks
// The code compiles but it has some problems and
// inefficiencies.  Describe what its trying to do, then
// comment on the bugs and how to fix them.  Also please give suggestions on
// how to improve the method. Name relevant softwareprinciples



bool Item::SetInt( INT_STAT key, int val, UpdateType update )
{

  m_Something->SetInt( key, val );

  int i;
  bool retval;

  byte* buffer = new byte[ 256 ];

  if ( update & No_UpdateType == No_UpdateType )
  {
    return false;
  }


  if ( update & Private_UpdateType == Private_UpdateType )
  {

    for ( i = 0; i < m_numEvents; ++i )
      {
        if ( m_eventFilter[i] == key )
		{
          retval = true;
        } 
		else 
		{
          retval = false;
        }
      }

    if ( retval ) {
      SendPrivateEvent( buffer, key, val );
    }
  }


  if ( update & Public_UpdateType == Public_UpdateType ) 
  {
  
    for ( i = 0; i < m_numEvents; ++i )
      {
         if ( m_eventFilter[i] == key ) 
		 {
           retval = true;
         }
		 else 
		 {
           retval = false;
         }
      }

    if ( retval ) 
	{
      SendPublicEvent( buffer, key, val );
    }
  }


  delete buffer;

  return retval;
}

My Answers:
//This function returns a boolean (true or false);
// if No_UpdateType, this function quits and exits with a return value of false
// if Private_UpdateType || public_UpdateType, we will check to see if the key
//passed in exists in the m_eventFilter Array, if it does, we will "sendPublicNetworkEvent" 
//or "sendPrivateNetworkEvent" respectively

//////////////////////////////////
//Inefficiencies and Suggestions:
//////////////////////////////////
//buffer was never initialized
//buffer in this example is passed as an argumeatnt, but was never implemented (no data assigned to it)
//If the buffer meant to be used as an output, it should have been passed as a refernce (&buffer)

//In the if conditional statements, update is being used as a boolean, to evaluate a boolean expresion with
//a mask - not good practise.

//if m_eventFilter is a larger array, it makes the search for the key expensive,
//it would be more efficient to use a Map for look up
//worst case scenario, if array had to be used, I would break out of the loop once key is found.

//redundant repetitive code

//This switch logic is popular in C++ design patterns, in designs where code reacts to the change of 
//object state, State Design Patterns as well as Observer patterns are ideal.
//So, when updateObjectType changes, the appropriate handler can be called at runtime.

AnswerRe: C++ Question Pin
Niklas L7-Jun-11 3:00
Niklas L7-Jun-11 3:00 
GeneralRe: C++ Question Pin
Stefan_Lang7-Jun-11 3:05
Stefan_Lang7-Jun-11 3:05 
GeneralRe: C++ Question Pin
Niklas L7-Jun-11 3:26
Niklas L7-Jun-11 3:26 
AnswerRe: C++ Question Pin
Stefan_Lang7-Jun-11 3:00
Stefan_Lang7-Jun-11 3:00 
GeneralRe: C++ Question Pin
Software20077-Jun-11 6:03
Software20077-Jun-11 6:03 
QuestionMiddleware/CORBA Data Field Inheritance Pin
rkeeler786-Jun-11 14:11
rkeeler786-Jun-11 14:11 
QuestionSuddenly Exe is not running Pin
pix_programmer6-Jun-11 3:16
pix_programmer6-Jun-11 3:16 
AnswerRe: Suddenly Exe is not running Pin
Alan Balkany6-Jun-11 10:21
Alan Balkany6-Jun-11 10:21 
AnswerRe: Suddenly Exe is not running Pin
Stefan_Lang7-Jun-11 3:17
Stefan_Lang7-Jun-11 3:17 
GeneralRe: Suddenly Exe is not running Pin
pix_programmer7-Jun-11 3:49
pix_programmer7-Jun-11 3:49 
GeneralRe: Suddenly Exe is not running Pin
Stefan_Lang7-Jun-11 3:55
Stefan_Lang7-Jun-11 3:55 
GeneralRe: Suddenly Exe is not running Pin
pix_programmer7-Jun-11 4:00
pix_programmer7-Jun-11 4:00 
GeneralRe: Suddenly Exe is not running Pin
Stefan_Lang7-Jun-11 4:26
Stefan_Lang7-Jun-11 4:26 
QuestionDisplay CBitmap into CStatic [modified] Pin
_Flaviu6-Jun-11 2:54
_Flaviu6-Jun-11 2:54 
AnswerRe: Display CBitmap into CStatic Pin
Roger Allen6-Jun-11 3:24
Roger Allen6-Jun-11 3:24 
GeneralRe: Display CBitmap into CStatic Pin
_Flaviu6-Jun-11 3:39
_Flaviu6-Jun-11 3:39 
QuestionCStatic ModifyStyle Pin
_Flaviu6-Jun-11 2:00
_Flaviu6-Jun-11 2:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.