在main函数之外执行函数的情

1、onexit函数

#include "stdafx.h"
#include "iostream"
#include 
using namespace std;

int func()								//必须为int返回值
{
	cout<<"This is after main function"<


2、全局对象的构建

#include "stdafx.h"
#include "iostream"
#include 
using namespace std;

class A
{
public:
	A()
	{
		cout<<"This is A's constructor"<


3、析构函数的调用

#include "stdafx.h"
#include "iostream"
#include 
using namespace std;

class A
{
public:
	A()
	{
		cout<<"This is A's constructor"<


你可能感兴趣的:(C/C++)