title: How to disable printf function?
body: <p>I have three files as below</p>
  
  <p><code>Test.cpp</code></p>
  
  <pre><code>void helloworld()
  {
      disable pf;
      pf.Disable();
      printf("No statement \n");
      }
  int main()
  {
      disable dis;
      helloworld();
      printf("Hello World");
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p><code>disable.cpp</code></p>
  
  <pre><code>    #include "StdAfx.h"
      #include "disable.h"
      disable::disable(void)
      {#define printf(fmt, ...) (0)}
      disable::~disable(void)
     {}
     void disable::Disable()
     {
      #define printf(fmt, ...) (0)
      }
  </code></pre>
  
  <p><code>disable.h</code></p>
  
  <pre><code>#pragma once
  class disable
  {
  public:
      disable(void);
      ~disable(void);
      void Disable();
  };
  </code></pre>
  
  <p>After executing, I am getting output as <code>No Statement</code> <code>Hello World</code>.
  But I would like to disable these <code>two printf statements</code> by calling <code>Disable function</code> and <code>disable constructor</code>..
  Please help me why it is not working and how to solve this. Please help.</p>
  
  <p>But things works fine if I do like</p>
  
  <pre><code>main()
  {
  #define printf(fmt, ...) (0)
  printf("Hello World");
  }
  </code></pre>
  
  <p>But why not if I am calling it from a function?</p>