Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) YodaConditionExample1

 

STLQt CreatorWindows

 

Yoda condition example 1: basics is a Yoda condition example.

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppYodaConditionExample1/CppYodaConditionExample1.pro

 

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
QMAKE_CXXFLAGS += -Wall -Wextra -Weffc++ -Werror
SOURCES += main.cpp

 

 

 

 

 

./CppYodaConditionExample1/main.cpp

 

#include <cstdlib>
#include <iostream>

int main()
{
  const int value = 1 + (std::rand() % 6);
  if (6 == value) //A Yoda condition
  {
    std::cout << "Six you drawn have\n"; //Yoda grammar
  }
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml