Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Namespace
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//g++ 7.4.0 //namespace: use of different namespaces //this code is created by Rezaul Hoque on August 27,2021;contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <iostream> namespace Garden{ class Vegetable{ public: void greet(){ std::cout<<"This is the vegetable plot.";} void tomato(){std::cout<<"tomato ";} void cucumber(){std::cout<<"cucumber ";} void pumpkin(){std::cout<<" pumpkin";} }; class Flower{ public: void greet(){ std::cout<<"This is the flower plot.";} void rose(){ std::cout<<"rose";} void nightqueen(){std::cout<<"night queen ";} }; class Fruit { public: void greet(){ std::cout<<"This is the fruit plot.";} void guava(){std::cout<<"guava ";} void strawberry(){std::cout<<"strawberry";} void papaya(){std::cout<<"papaya ";} }; } namespace Greetings{ void Start(){std::cout<<"Welcome to my garden.";} void Pose(){std::cout<<"Isn’t it beautiful?";} void Fin(){std::cout<<"Hope you enjoy the tour at my garden.";} } int main() { Garden::Vegetable veg; Garden::Flower flow; Garden::Fruit fr; Greetings::Start(); std::cout<<"\n"; veg.greet(); std::cout<<"\n"; std::cout<<"Here we have "; veg.tomato(); std::cout<<","; veg.cucumber(); std::cout<<"&"; veg.pumpkin(); std::cout<<"."; std::cout<<" \n"; Greetings::Pose(); std::cout<<"\n"; flow.greet(); std::cout<<"\n"; std::cout<<"Here we have "; flow.nightqueen(); std::cout<<"&"; flow.rose(); std::cout<<"."; std::cout<<"\n"; Greetings::Pose(); std::cout<<"\n"; fr.greet(); std::cout<<"\n"; std::cout<<"Here we have "; fr.guava(); std::cout<<","; fr.papaya(); std::cout<<"& "; fr.strawberry(); std::cout<<"."; std::cout<<"\n"; Greetings::Fin(); return 0; }
g++
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion