初始提交
This commit is contained in:
81
app/cpp_demo/demo.cpp
Normal file
81
app/cpp_demo/demo.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/****************************************************************************
|
||||
|
||||
Copyright(c) 2019 by Aerospace C.Power (Chongqing) Microelectronics. ALL RIGHTS RESERVED.
|
||||
|
||||
This Information is proprietary to Aerospace C.Power (Chongqing) Microelectronics and MAY NOT
|
||||
be copied by any method or incorporated into another program without
|
||||
the express written consent of Aerospace C.Power. This Information or any portion
|
||||
thereof remains the property of Aerospace C.Power. The Information contained herein
|
||||
is believed to be accurate and Aerospace C.Power assumes no responsibility or
|
||||
liability for its use in any way and conveys no license or title under
|
||||
any patent or copyright and makes no representation or warranty that this
|
||||
Information is free from patent or copyright infringement.
|
||||
|
||||
****************************************************************************/
|
||||
|
||||
#include "iot_io_api.h"
|
||||
#include "iot_config_api.h"
|
||||
#include "os_utils_api.h"
|
||||
|
||||
class class_test {
|
||||
public:
|
||||
int len;
|
||||
int size;
|
||||
int print(int a, int b);
|
||||
int print(int a, int b, int c);
|
||||
};
|
||||
|
||||
int class_test::print(int a, int b)
|
||||
{
|
||||
iot_printf("[class test] argv(%d,%d): rst: (%d)\n", a, b, a+b);
|
||||
}
|
||||
|
||||
int class_test::print(int a, int b, int c)
|
||||
{
|
||||
iot_printf("[class test] argv(%d,%d,%d): rst: (%d)\n", a, b, c, a + b + c);
|
||||
}
|
||||
|
||||
class temp_test {
|
||||
public:
|
||||
template<typename T>
|
||||
int add(const T& t) {
|
||||
iot_printf("[template test] argv(%d)\n", t);
|
||||
return t*2;
|
||||
}
|
||||
};
|
||||
|
||||
class_test g_test;
|
||||
uint32_t cpp_feature_test()
|
||||
{
|
||||
temp_test temp;
|
||||
int c = 0;
|
||||
while(1) {
|
||||
iot_printf("\n{test new and malloc feature}\n");
|
||||
class_test *test = new class_test();
|
||||
test->len = 34;
|
||||
test->size = 45;
|
||||
test->print(30, 40);
|
||||
test->print(30, 40, 50);
|
||||
delete[] test;
|
||||
|
||||
iot_printf("\n{test global variable feature}\n");
|
||||
g_test.len = 66;
|
||||
g_test.size = 77;
|
||||
g_test.print(55, 66);
|
||||
g_test.print(55, 66, 77);
|
||||
|
||||
iot_printf("\n{test template feature}\n");
|
||||
c = temp.add(10);
|
||||
iot_printf("[template test] rst: %d\n", c);
|
||||
|
||||
os_delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t app_demo_entry()
|
||||
{
|
||||
cpp_feature_test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user