1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - OS - demos - cplusplus-1
3 File: main.c
4
5 Copyright 2003-2008 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Date:: 2007-09-19#$
14 $Rev: 1027 $
15 $Author: yada $
16 *---------------------------------------------------------------------------*/
17 #include <nitro.h>
18 #include "new.h"
19
20 //================================================================
21 // Foo
22 //
23 class Foo
24 {
25 private:
26 u32 a;
27 u32 b;
28 int* array;
29
30 public:
31 Foo();
32 ~Foo();
33
printA(void)34 void printA(void)
35 {
36 OS_Printf("a = %d\n", a);
37 }
38 void printB(void);
39
printArray(void)40 void printArray(void)
41 {
42 for( int n=0; n<16; n++ ){ OS_Printf("%d ", array[n]); }
43 OS_Printf("\n");
44 }
45 };
46
47 /*---------------------------------------------------------------------------*
48 Name: Foo::Foo
49
50 Description: Constructor for class Foo.
51 Simply initialize private members.
52
53 Arguments: None
54
55 Returns: None
56 *---------------------------------------------------------------------------*/
Foo()57 Foo::Foo()
58 {
59 a = 1234;
60 b = 5678;
61
62 array = new int[16];
63 for( int n=0; n<16; n++ ){ array[n] = n; }
64 }
65
66 /*---------------------------------------------------------------------------*
67 Name: Foo::~Foo
68
69 Description: Destructor for class Foo.
70 Performs an OSReport so we know it got called properly.
71
72 Arguments: None
73
74 Returns: None
75 *---------------------------------------------------------------------------*/
~Foo()76 Foo::~Foo()
77 {
78 OS_Printf("Foo destructor\n");
79 }
80
81 /*---------------------------------------------------------------------------*
82 Name: Foo::printB
83
84 Description: function to print out b member
85
86 Arguments: None
87
88 Returns: None
89 *---------------------------------------------------------------------------*/
printB()90 void Foo::printB()
91 {
92 OS_Printf("b = %d\n", b);
93 }
94
95
96
97 //================================================================================
98 //---- static class instanse
99 static Foo staticFoo;
100
101 //--------------------------------------------------------------------------------
102 // NitroMain
103 //
NitroMain()104 void NitroMain()
105 {
106 // needless to call OS_Init() because called in NitroStartUp()
107 //OS_Init();
108
109 Foo* foo;
110 foo = new Foo;
111
112 foo->printA();
113 foo->printB();
114 foo->printArray();
115
116 staticFoo.printA();
117 staticFoo.printB();
118 staticFoo.printArray();
119
120 OS_Printf("==== Finish sample.\n");
121 OS_Terminate();
122 }
123