1. the main. c postfix main. cpp
/*****************************************************************************
*
* File Name : main. c
*
* Description: main
*
* Copyright (c) 2014 Winner Micro Electronic Design Co. , Ltd.
* All rights reserved.
*
* Author : dave
*
* Date : 2014-6-14
*****************************************************************************/
#include "wm_include. h"
class Line
{
public:
void setLength ( double len ) ;
double getLength ( void ) ;
Line () ; // This is the constructor declaration
~Line () ; // This is the destructor declaration
private:
double length;
};
// Member function definition, Inclusive constructor
Line: : Line (void)
{
printf ("Object is being created\n") ;
}
Line: : ~Line (void)
{
printf ("Object is being deleted\n") ;
}
void Line: : setLength ( double len )
{
length = len;
}
double Line: : getLength ( void )
{
return length;
}
#ifdef __cplusplus
extern "C" {
#endif
void UserMain (void)
{
printf ("\n user task \n") ;
Line line;
// Set length
line. setLength (6. 0) ;
printf ("Length of line : %lf\n", line. getLength () ) ;
#if DEMO_CONSOLE
CreateDemoTask () ;
#endif
//user-owned task
}
#ifdef __cplusplus
}
#endif
2. LINKFLAGS add-lsupc++ (Otherwise, the inclusion destructor will report an error)
3. Demo effect