Menu
Coddy logo textTech

Stack Class

Lesson 3 of 13 in Coddy's Stack - Data Structures Series #1 course.

The Stack data structure we will create, will store only integers.

Every time you create a data structure, you should decide how to handle the elements of the data structure internally.

The most popular way is with an array, but there are many ways that differ from one programming language to another.

During this project, we will take you hand in hand while creating the Stack class, but you will need to decide how to implement everything internally.

If you are stuck don't hesitate to use our support for help!

challenge icon

Challenge

Easy

Write a class Stack with a constructor that gets no input.

In the constructor initialize class variable that will hold the stack elements, start from an empty array.

Try it yourself

#include <stdio.h>
#include "stack.h"

int main() {
    Stack stack;
    Stack_init(&stack);
    printf("%d\n", stack.size);
    return 0;
}

All lessons in Stack - Data Structures Series #1