new

リスト作成の際の注意

リスト作成して、ノードを挿入したい。 #include using namespace std; typedef struct _list { int data; struct _list *next; }MyList; class Node { public: Node(); ~Node(); private: MyList* m_head; public: void Insert(int num); void Disp(); }; N…

2:複数の注文に対応する。

動的にメモリを確保する練習というか、復習。 int main() { //intの大きさのメモリを確保する。 //メモリの位置はnewが返してくれるので、ポインタに入れておく。 Product* p = new Pruduct; //本来ならば、(*p).Disp()のような形でアクセスしなければならな…