(a) pch.h
// Sun Forte C++: The contents of this file will be
//           included through normal C++ semantics.
// MS Visual C++: The contents of this file will be 
//           included through the precompiled header.
#include <iostream.h>
#define STR1 "James "
#define STR2 "Brown"

(b) pch.cpp
// Do add anything to this file!
// Any additional code should be placed in pch.h.
#include "pch.h"

(c) main.cpp
#include "pch.h"

int main()
{
	cout << STR1;
	cout << STR2;
	return 0;
}

Example 2: This C++ program has the same behavior on NT and UNIX: (a) pch.h; (b) pch.cpp; (c) main.cpp.

Back to Article