如果你不想做某些事情,那就找个对象吧!

       test.h:

#ifndef me
#define me

class A
{
public:
	A();
	void print();
};

#endif
      test.cpp:

#include <iostream>
#include "test.h"
using namespace std;

A::A()
{
}	

void A :: print()
{
	cout << "hello" << endl;
}
     main.cpp:

#include <iostream>
#include "test.h"
using namespace std;

int main()
{
	A a;
	a.print();
	
	return 0;
}

     Done.







本文转载:CSDN博客