my-cool-project  3.1.0
Starter template for C++ projects built with Bazel
Loading...
Searching...
No Matches
greeter::Greeter Class Reference

A class for saying hello in multiple languages. More...

#include <greeter.h>

Public Member Functions

 Greeter (std::string name)
 Constructs a new Greeter object.
 
std::string greet (LanguageCode lang=LanguageCode::EN) const
 Creates a localized greeting string.
 

Private Attributes

std::string name
 

Detailed Description

A class for saying hello in multiple languages.

The Greeter class allows you to create personalized greeting messages in different languages. It stores a name and provides a method to generate a greeting string localized to the specified language.

Note
Currently supported languages are English, German, Spanish, and French.
Example
greeter::Greeter g("Alice");
std::cout << g.greet(greeter::LanguageCode::FR) << std::endl; // Bonjour, Alice!
A class for saying hello in multiple languages.
Definition greeter.h:47

Constructor & Destructor Documentation

◆ Greeter()

greeter::Greeter::Greeter ( std::string name)
explicit

Constructs a new Greeter object.

Parameters
nameThe name to greet

Initializes the Greeter with the given name. This name will be used in the greeting messages.

Exceptions
std::invalid_argumentif the name is empty

Member Function Documentation

◆ greet()

std::string greeter::Greeter::greet ( LanguageCode lang = LanguageCode::EN) const

Creates a localized greeting string.

Parameters
langThe language code to use for the greeting (default is English)
Returns
A std::string containing the greeting message

Generates a greeting message in the specified language. If the language is not recognized, it defaults to English.

Supported greetings:

  • English: "Hello, <name>!"
  • German: "Hallo, <name>!"
  • Spanish: "¡Hola, <name>!"
  • French: "Bonjour, <name>!"
Note
The returned string includes punctuation and capitalization appropriate for the language.

Member Data Documentation

◆ name

std::string greeter::Greeter::name
private

The name of the person to greet


The documentation for this class was generated from the following files: