GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com β€” GitHub - dataproctech/singleton: Educational repository demonstrating the Singleton design pattern in Java and C++. Includes simple, clear implementations for students to explore, compile, and run.

BranchesTags
Open more actions menu

Latest commit

 

History

3 Commits
3 Commits

Folders and files

NameName
Last commit message
Last commit date
Geeks.java
Geeks.java
 
 
README.md
README.md
 
 
main.cpp
main.cpp
 
 

Repository files navigation

Singleton Pattern β€” Java & C++ Examples

This repository provides a minimal and easy-to-understand implementation of the Singleton design pattern in Java and C++. The goal is to help students learn how the pattern works, why it is used, and how to run simple example implementations on their own.


πŸ“Œ What is the Singleton Pattern?

The Singleton pattern ensures that a class has only one instance during the program’s lifetime and provides a global point of access to it.

Typical use cases include:

  • Configuration managers
  • Logger classes
  • Database connection managers
  • Global state containers

Both examples in this repository demonstrate:

  • A private constructor
  • A static method that returns the single instance
  • Prevention of copying or instantiation from outside

βœ” Java Example (Geeks.java)

This file shows a classical lazy-initialized Singleton in Java.

βœ” C++ Example (main.cpp)

This file demonstrates a simple pointer-based Singleton implementation in C++ (and confirms that two calls return the same instance). The example corresponds to the uploaded code .


β–Ά How to Run the Examples

Run the Java Version

  1. Navigate to the folder:

    cd java
  2. Compile:

    javac Geeks.java
  3. Run:

    java Geeks

Run the C++ Version

  1. Navigate to the folder:

    cd cpp
  2. Compile:

    g++ main.cpp -o singleton
  3. Run:

    ./singleton

🧠 Learning Objectives

By experimenting with these files, you will learn:

  • How Singleton works in Java and C++
  • How constructors are hidden to prevent multiple instances
  • How static methods provide access to the single object
  • How memory allocation differs between languages (JVM vs manual C++)
  • Why Singleton must block copying (deleted copy constructor in C++)

πŸŽ“ License & Usage

This repository is created purely for educational purposes.

You are encouraged to modify the examples and experiment with alternative Singleton implementations.

About

Educational repository demonstrating the Singleton design pattern in Java and C++. Includes simple, clear implementations for students to explore, compile, and run.

Resources

Readme
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 β€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Γ—600. No cookies required.