The document discusses C++ scope resolution operator (::) and pointers. It explains that :: is used to qualify hidden names and access variables or functions in the global namespace when a local variable hides it. It also discusses pointers, which are variables that store memory addresses. Pointers allow dynamic memory allocation and are useful for passing arguments by reference. Key pointer concepts covered include null pointers, pointer arithmetic, relationships between pointers and arrays, arrays of pointers, pointer to pointers, and passing/returning pointers in functions.
This document provides an introduction to C++ programming. It covers basic concepts like variables, data types, input/output statements, conditional statements, loops, arrays, functions, and classes. Some key points:
- A C++ program consists of variable declarations, input/output statements, computations, and printing output. Comments begin with //.
- Variables are declared with a data type like int or double followed by the name. Input is done with cin and output with cout.
- Conditional statements like if-else and loops like while are used to control program flow. Boolean conditions use comparison and logical operators.
- Arrays allow storing multiple values of a type. Functions can be predefined or programmer-
This document provides an overview of the C++ Data Structures lab manual. It covers topics like C++ review, implementation of various data structures like stack, queue, linked list, binary tree, graph. It also discusses sorting and searching techniques, file input/output, functions, classes, templates and exercises for students to practice implementing different data structures and algorithms. The instructor's contact details are provided at the beginning.
Classes allow programmers to create new types that model real-world objects. A class defines both data attributes and built-in operations that can operate on that data. C++ provides built-in classes like string and iostream that add powerful functionality to the language. The string class allows easy storage and manipulation of strings, while the iostream classes (istream and ostream) define objects like cin and cout for input/output. These classes provide many useful built-in operations that make input/output powerful yet easy to use.
This document provides an overview of key C# programming concepts such as declaring variables, data types, conditional statements, loops, namespaces, and more. It also discusses topics like initialization and scope of variables, predefined value and reference types, if statements, and using the console for input/output. The goal is to cover basic C# syntax, conventions, and compiler options to get started with programming in C#.
The document discusses C++ scope resolution operator (::) and pointers. It explains that :: is used to qualify hidden names and access variables or functions in the global namespace when a local variable hides it. It also discusses pointers, which are variables that store memory addresses. Pointers allow dynamic memory allocation and are useful for passing arguments by reference. Key pointer concepts covered include null pointers, pointer arithmetic, relationships between pointers and arrays, arrays of pointers, pointer to pointers, and passing/returning pointers in functions.
This document provides an introduction to C++ programming. It covers basic concepts like variables, data types, input/output statements, conditional statements, loops, arrays, functions, and classes. Some key points:
- A C++ program consists of variable declarations, input/output statements, computations, and printing output. Comments begin with //.
- Variables are declared with a data type like int or double followed by the name. Input is done with cin and output with cout.
- Conditional statements like if-else and loops like while are used to control program flow. Boolean conditions use comparison and logical operators.
- Arrays allow storing multiple values of a type. Functions can be predefined or programmer-
This document provides an overview of the C++ Data Structures lab manual. It covers topics like C++ review, implementation of various data structures like stack, queue, linked list, binary tree, graph. It also discusses sorting and searching techniques, file input/output, functions, classes, templates and exercises for students to practice implementing different data structures and algorithms. The instructor's contact details are provided at the beginning.
Classes allow programmers to create new types that model real-world objects. A class defines both data attributes and built-in operations that can operate on that data. C++ provides built-in classes like string and iostream that add powerful functionality to the language. The string class allows easy storage and manipulation of strings, while the iostream classes (istream and ostream) define objects like cin and cout for input/output. These classes provide many useful built-in operations that make input/output powerful yet easy to use.
This document provides an overview of key C# programming concepts such as declaring variables, data types, conditional statements, loops, namespaces, and more. It also discusses topics like initialization and scope of variables, predefined value and reference types, if statements, and using the console for input/output. The goal is to cover basic C# syntax, conventions, and compiler options to get started with programming in C#.
The Ring programming language version 1.8 book - Part 94 of 202Mahmoud Samir Fayed
This document provides code examples for common GUI tasks in Ring using the Qt library:
1. It shows how to close a window and display another by connecting a button's click event to call the close() method on the first window and show() on the second.
2. It demonstrates how to create a modal window in Ring/Qt by setting the window modality to true and parent to the main window.
3. Methods like setWindowFlags() and removing the maximize flag can disable resizing and maximize buttons on a window.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
The document provides an overview of the C programming language. It begins by explaining that Objective-C extends standard ANSI C with object-oriented capabilities. It then discusses why C remains important today due to its use in libraries, operating systems, and as the base for many other popular languages. The document proceeds to cover basic C concepts like variables, data types, functions, flow control, pointers, memory allocation, and I/O parameters. It emphasizes that C provides high performance with a minimal footprint while abstracting away the CPU and memory.
The document discusses function overloading in C++ and provides an example program to calculate the area of different shapes using function overloading. It then discusses constructors and destructors with examples and explains polymorphism with an example. Next, it discusses different types of inheritance in C++ and provides an example program to implement operator overloading for a distance class. It also discusses virtual functions with an example and access specifiers in classes. Finally, it provides examples to define a student class, implement quicksort using templates and overloading relational operators.
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
This document provides examples and explanations for common questions about using Ring programming language. It demonstrates how to summarize uninitialized variables, print lists containing objects, insert items into lists, print new lines and characters, create GUI applications using Qt, work with modal windows, and connect to SQLite and other databases using ODBC. Various functions, classes and concepts in Ring like Try/Catch, NULL, ISNULL(), lists, Qt classes and ODBC are explained through code examples.
Namespaces can group related code such as classes, objects, and functions to prevent naming collisions. Exceptions provide a way to handle errors and problems that occur in programs by bubbling the error up the call stack. Standard exceptions like bad_alloc are thrown for issues like memory allocation failures. Custom exception classes can be created to specify the type of error. Exception specifications declare what types of exceptions a function is allowed to throw.
This document provides an overview of JavaScript development challenges and how EcmaScript 2015 and TypeScript address these challenges. It discusses the rise of JavaScript, traditional development challenges like lack of structuring capabilities and static types, new features in EcmaScript 2015 like arrow functions and classes, and how TypeScript adds static types and interfaces to provide benefits for large application development. The document contains code examples to demonstrate various JavaScript and TypeScript language features.
Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
This document provides an overview of key concepts in programming and Python. It defines terms like code, syntax, output, console, compiling, interpreting, and variables. It explains Python as an interpreted language and shows examples of printing output, taking user input, performing calculations with numbers and math commands, using variables, and basic control structures like if/else and loops. It also covers data types like integers, floats, strings, lists, and how to modify and format them.
This document summarizes new features introduced in ES2015 (ES6), including let and const block scoping, arrow functions, template literals, destructuring, classes, modules, and methods added to built-in objects like String, Array, Number, Math and more. It recommends using features like let, const, arrow functions, and template literals that improve code clarity and syntax, while being cautious of less supported features like iterators, generators and proxies that may require polyfills or have limited browser support. The document provides examples and explanations of many ES6 features and references additional learning resources.
The document provides examples of code snippets in C# to demonstrate various OOP concepts like inheritance, polymorphism, delegates, constructors, exception handling, file I/O, and adding a flash item to a website. It also explains XML and DTDs. The code snippets show how to implement inheritance by defining a base Shape class and derived Rectangle class, implement polymorphism by overloading a print method, use delegates to call methods, define default and parameterized constructors, handle exceptions, perform file read/write operations, and add a flash file to an HTML document. The explanation of XML covers internal and external DTD declarations to define document structure.
ES6 is Nigh is a presentation on the future of JavaScript. It discusses the history of JavaScript and why ES6 is important for advancing the language. The presentation outlines many new features being added in ES6, such as arrow functions, classes, modules, template strings, symbols, generators, and proxies. It emphasizes that ES6 is purely additive and introduces these features without breaking backwards compatibility.
The document provides information about constructors and destructors in C++. It discusses various topics like:
- Constructor is a special member function that initializes objects of a class. It has the same name as the class and is executed when an object is created.
- Member functions of a class can be defined inside or outside the class. When defined outside, the scope resolution operator (::) is used.
- Constructor overloading allows defining multiple constructors with the same name but different parameters.
- Copy constructor initializes an object using another object of the same class. The default copy constructor is available by default.
- Destructor is a special member function that cleans up an object
The document discusses C++ functions. It explains that functions allow code to be reused by grouping common operations into reusable blocks of code called functions. Functions have three parts: a prototype that declares the function, a definition that implements it, and calls that execute the function. Functions can take parameters as input and return a value. Grouping common code into well-named functions makes a program more organized and maintainable.
The document discusses object-oriented programming concepts including encapsulation, inheritance, and polymorphism. It provides an example class called Point that demonstrates defining data members and member functions. It then provides a more detailed example of a Set class that implements common set operations like adding/removing elements and computing intersections/unions. The document also discusses constructors and destructors and how they are used to initialize and clean up class objects.
C# 3.0 introduces many features common in functional programming languages like generics, first-class functions, lambda expressions, and type inference. However, C# retains its object-oriented roots, and some features like datatypes and laziness remain more fully realized in pure functional languages. While C# supports programming in a functional style, its performance characteristics and lack of optimizations mean it may not be a serious competitor to ML and Haskell for functional programming tasks.
C++ is an object-oriented programming language that is an extension of C. It was developed in the early 1980s by Bjarne Stroustrup at Bell Labs. C++ supports concepts like inheritance, polymorphism, and encapsulation that make it suitable for large, complex programs. Inheritance allows classes to inherit properties from parent classes. Polymorphism is the ability to process objects of different types in the same way. Encapsulation combines data and functions that operate on that data within a single unit, hiding implementation details. File input/output in C++ can be handled through streams like ifstream for input and ofstream for output.
The Ring programming language version 1.8 book - Part 94 of 202Mahmoud Samir Fayed
This document provides code examples for common GUI tasks in Ring using the Qt library:
1. It shows how to close a window and display another by connecting a button's click event to call the close() method on the first window and show() on the second.
2. It demonstrates how to create a modal window in Ring/Qt by setting the window modality to true and parent to the main window.
3. Methods like setWindowFlags() and removing the maximize flag can disable resizing and maximize buttons on a window.
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
The document provides an overview of the C programming language. It begins by explaining that Objective-C extends standard ANSI C with object-oriented capabilities. It then discusses why C remains important today due to its use in libraries, operating systems, and as the base for many other popular languages. The document proceeds to cover basic C concepts like variables, data types, functions, flow control, pointers, memory allocation, and I/O parameters. It emphasizes that C provides high performance with a minimal footprint while abstracting away the CPU and memory.
The document discusses function overloading in C++ and provides an example program to calculate the area of different shapes using function overloading. It then discusses constructors and destructors with examples and explains polymorphism with an example. Next, it discusses different types of inheritance in C++ and provides an example program to implement operator overloading for a distance class. It also discusses virtual functions with an example and access specifiers in classes. Finally, it provides examples to define a student class, implement quicksort using templates and overloading relational operators.
The Ring programming language version 1.3 book - Part 83 of 88Mahmoud Samir Fayed
This document provides examples and explanations for common questions about using Ring programming language. It demonstrates how to summarize uninitialized variables, print lists containing objects, insert items into lists, print new lines and characters, create GUI applications using Qt, work with modal windows, and connect to SQLite and other databases using ODBC. Various functions, classes and concepts in Ring like Try/Catch, NULL, ISNULL(), lists, Qt classes and ODBC are explained through code examples.
Namespaces can group related code such as classes, objects, and functions to prevent naming collisions. Exceptions provide a way to handle errors and problems that occur in programs by bubbling the error up the call stack. Standard exceptions like bad_alloc are thrown for issues like memory allocation failures. Custom exception classes can be created to specify the type of error. Exception specifications declare what types of exceptions a function is allowed to throw.
This document provides an overview of JavaScript development challenges and how EcmaScript 2015 and TypeScript address these challenges. It discusses the rise of JavaScript, traditional development challenges like lack of structuring capabilities and static types, new features in EcmaScript 2015 like arrow functions and classes, and how TypeScript adds static types and interfaces to provide benefits for large application development. The document contains code examples to demonstrate various JavaScript and TypeScript language features.
Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
This document provides an overview of key concepts in programming and Python. It defines terms like code, syntax, output, console, compiling, interpreting, and variables. It explains Python as an interpreted language and shows examples of printing output, taking user input, performing calculations with numbers and math commands, using variables, and basic control structures like if/else and loops. It also covers data types like integers, floats, strings, lists, and how to modify and format them.
This document summarizes new features introduced in ES2015 (ES6), including let and const block scoping, arrow functions, template literals, destructuring, classes, modules, and methods added to built-in objects like String, Array, Number, Math and more. It recommends using features like let, const, arrow functions, and template literals that improve code clarity and syntax, while being cautious of less supported features like iterators, generators and proxies that may require polyfills or have limited browser support. The document provides examples and explanations of many ES6 features and references additional learning resources.
The document provides examples of code snippets in C# to demonstrate various OOP concepts like inheritance, polymorphism, delegates, constructors, exception handling, file I/O, and adding a flash item to a website. It also explains XML and DTDs. The code snippets show how to implement inheritance by defining a base Shape class and derived Rectangle class, implement polymorphism by overloading a print method, use delegates to call methods, define default and parameterized constructors, handle exceptions, perform file read/write operations, and add a flash file to an HTML document. The explanation of XML covers internal and external DTD declarations to define document structure.
ES6 is Nigh is a presentation on the future of JavaScript. It discusses the history of JavaScript and why ES6 is important for advancing the language. The presentation outlines many new features being added in ES6, such as arrow functions, classes, modules, template strings, symbols, generators, and proxies. It emphasizes that ES6 is purely additive and introduces these features without breaking backwards compatibility.
The document provides information about constructors and destructors in C++. It discusses various topics like:
- Constructor is a special member function that initializes objects of a class. It has the same name as the class and is executed when an object is created.
- Member functions of a class can be defined inside or outside the class. When defined outside, the scope resolution operator (::) is used.
- Constructor overloading allows defining multiple constructors with the same name but different parameters.
- Copy constructor initializes an object using another object of the same class. The default copy constructor is available by default.
- Destructor is a special member function that cleans up an object
The document discusses C++ functions. It explains that functions allow code to be reused by grouping common operations into reusable blocks of code called functions. Functions have three parts: a prototype that declares the function, a definition that implements it, and calls that execute the function. Functions can take parameters as input and return a value. Grouping common code into well-named functions makes a program more organized and maintainable.
The document discusses object-oriented programming concepts including encapsulation, inheritance, and polymorphism. It provides an example class called Point that demonstrates defining data members and member functions. It then provides a more detailed example of a Set class that implements common set operations like adding/removing elements and computing intersections/unions. The document also discusses constructors and destructors and how they are used to initialize and clean up class objects.
C# 3.0 introduces many features common in functional programming languages like generics, first-class functions, lambda expressions, and type inference. However, C# retains its object-oriented roots, and some features like datatypes and laziness remain more fully realized in pure functional languages. While C# supports programming in a functional style, its performance characteristics and lack of optimizations mean it may not be a serious competitor to ML and Haskell for functional programming tasks.
C++ is an object-oriented programming language that is an extension of C. It was developed in the early 1980s by Bjarne Stroustrup at Bell Labs. C++ supports concepts like inheritance, polymorphism, and encapsulation that make it suitable for large, complex programs. Inheritance allows classes to inherit properties from parent classes. Polymorphism is the ability to process objects of different types in the same way. Encapsulation combines data and functions that operate on that data within a single unit, hiding implementation details. File input/output in C++ can be handled through streams like ifstream for input and ofstream for output.
Similar to Object Oriented Programming Using C++: C++ Namespaces.pptx (20)
artificial intelligence and data science contents.pptxGauravCar
What is artificial intelligence? Artificial intelligence is the ability of a computer or computer-controlled robot to perform tasks that are commonly associated with the intellectual processes characteristic of humans, such as the ability to reason.
› ...
Artificial intelligence (AI) | Definitio
Batteries -Introduction – Types of Batteries – discharging and charging of battery - characteristics of battery –battery rating- various tests on battery- – Primary battery: silver button cell- Secondary battery :Ni-Cd battery-modern battery: lithium ion battery-maintenance of batteries-choices of batteries for electric vehicle applications.
Fuel Cells: Introduction- importance and classification of fuel cells - description, principle, components, applications of fuel cells: H2-O2 fuel cell, alkaline fuel cell, molten carbonate fuel cell and direct methanol fuel cells.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...IJECEIAES
Climate change's impact on the planet forced the United Nations and governments to promote green energies and electric transportation. The deployments of photovoltaic (PV) and electric vehicle (EV) systems gained stronger momentum due to their numerous advantages over fossil fuel types. The advantages go beyond sustainability to reach financial support and stability. The work in this paper introduces the hybrid system between PV and EV to support industrial and commercial plants. This paper covers the theoretical framework of the proposed hybrid system including the required equation to complete the cost analysis when PV and EV are present. In addition, the proposed design diagram which sets the priorities and requirements of the system is presented. The proposed approach allows setup to advance their power stability, especially during power outages. The presented information supports researchers and plant owners to complete the necessary analysis while promoting the deployment of clean energy. The result of a case study that represents a dairy milk farmer supports the theoretical works and highlights its advanced benefits to existing plants. The short return on investment of the proposed approach supports the paper's novelty approach for the sustainable electrical system. In addition, the proposed system allows for an isolated power setup without the need for a transmission line which enhances the safety of the electrical network
Software Engineering and Project Management - Introduction, Modeling Concepts...Prakhyath Rai
Introduction, Modeling Concepts and Class Modeling: What is Object orientation? What is OO development? OO Themes; Evidence for usefulness of OO development; OO modeling history. Modeling
as Design technique: Modeling, abstraction, The Three models. Class Modeling: Object and Class Concept, Link and associations concepts, Generalization and Inheritance, A sample class model, Navigation of class models, and UML diagrams
Building the Analysis Models: Requirement Analysis, Analysis Model Approaches, Data modeling Concepts, Object Oriented Analysis, Scenario-Based Modeling, Flow-Oriented Modeling, class Based Modeling, Creating a Behavioral Model.
Discover the latest insights on Data Driven Maintenance with our comprehensive webinar presentation. Learn about traditional maintenance challenges, the right approach to utilizing data, and the benefits of adopting a Data Driven Maintenance strategy. Explore real-world examples, industry best practices, and innovative solutions like FMECA and the D3M model. This presentation, led by expert Jules Oudmans, is essential for asset owners looking to optimize their maintenance processes and leverage digital technologies for improved efficiency and performance. Download now to stay ahead in the evolving maintenance landscape.
2. Consider a situation, when we have two persons with the same name, M. Ali,
in the same class. Whenever we need to differentiate them definitely we
would have to use some additional information along with their name, like
either Reg. Number or their Father’s Name, etc.
Same situation can arise in your C++ program. For example, you might be
writing some code that has a function called print() and there is another
library available which is also having same function print(). Now the compiler
has no way of knowing which version of print() function you are referring to
within your code.
A namespace is designed to overcome this difficulty and is used as additional
information to differentiate similar functions, classes, variables etc. with the
Introduction
3. same name available in different libraries. Using namespace, you can define
the context in which names are defined. In essence, a namespace defines a
scope.
A namespace definition begins with the keyword namespace followed by the
namespace name.
To call the namespace-enabled version of either function or variable, write
scope resolution operator (::) between the namespace and the code:
Introduction
namespace namespace_name {
// code declarations
}
namespace_name::code
4. #include <iostream>
// Define a namespace called "MyNamespace"
namespace MyNamespace {
// Define a simple function within the namespace
void displayMessage() {
std::cout << "Hello from MyNamespace!" << std::endl;
}
}
int main() {
// Call the function from the namespace without using the namespace prefix
MyNamespace::displayMessage();
return 0;
}
Example 1: Using namespace
5. #include <iostream>
#include <stdlib.h>
namespace Cartesian_Coordinates {
double x = 11.2;
double y = 8.7;
void Show(){
std::cout<< "x = " << x
<< ", y = "<< y
<< std::endl;
}
}
Example 2: Using two namespaces
namespace Spherical_Coordinates {
double r = 14.18;
double theta = 37.84;
void Show(){
std::cout<< "r = " << r
<< ", Theta = " << theta
<< std::endl;
}
}
int main() {
Cartesian_Coordinates::Show();
Spherical_Coordinates::Show();
system("pause");
return 0;
}
Page 1 Page 2
6. #include <iostream>
#include <stdlib.h>
namespace Cartesian_Coordinates {
double x = 11.2;
double y = 8.7;
void Show(){
std::cout<< "x = " << x
<< ", y = "<< y
<< std::endl;
}
}
Example 3: The using directive
namespace Spherical_Coordinates {
double r = 14.18;
double theta = 37.84;
void Show(){
std::cout<< "r = " << r
<< ", Theta = " << theta
<< std::endl;
}
}
using namespace Spherical_Coordinates;
int main() {
Show(); // it will call Show from
// Spherical_Coordinates namespace
system("pause");
return 0;
}
Page 1 Page 2
7. #include <iostream>
// Define a namespace called "Shapes"
namespace Shapes {
class Circle {
private:
double radius;
public:
Circle(double radius):radius(radius) {}
double calculateArea() const {
return 3.14 * radius * radius;
}
};
}
Example 4: Using class in a namespace
int main() {
// Create an instance of the Circle class
// from the Shapes namespace
Shapes::Circle myCircle(5.0);
std::cout << "Area of the circle: "
<< myCircle.calculateArea()
<< std::endl;
return 0;
}
Page 1 Page 2
8. #include <iostream>
using namespace std;
namespace Geometry { // Define a namespace called "Geometry"
class Point { // Define a class called "Point" to represent a point in 2D space
public:
int x,y;
Point(int x, int y) : x(x), y(y) {}
void Show() const {
cout << "(" << x << ", " << y << ")";
}
};
class Rectangle {
private:
Point topLeft, bottomRight;
public:
Rectangle(Point TL, Point BR):topLeft(TL), bottomRight(BR) {}
void Draw() const {
int height = bottomRight.x - topLeft.x;
int width = bottomRight.y - topLeft.y;
Example 5: Using two classes in a namespace
Page 1
9. for(int row = 0 ; row < height ; row++){
for(int col = 0 ; col< width ; col++){
cout<<"*";
}
cout<<"n";
}
}
};
}
int main() {
// Create instances of classes from the Geometry namespace
Geometry::Point topLeft(5, 7); Geometry::Point bottomRight(8, 11);
cout << "Top Left = "; topLeft.Show(); cout <<"n";
cout << "Bottom Right = "; bottomRight.Show(); cout <<"n";
Geometry::Rectangle rectangle(topLeft, bottomRight);
rectangle.Draw();
return 0;
}
Example 5: Using two classes in a namespace
Page 2
10. Namespaces can be nested where you can define one namespace inside
another name space.
You can access members of nested namespace by using resolution operators.
Nested Namespaces
namespace namespace_name1 {
// code declarations
namespace namespace_name2 {
// code declarations
}
}
// to access members of namespace_name2
using namespace namespace_name1::namespace_name2;
// to access members of namespace:name1
using namespace namespace_name1;
11. #include <iostream>
#include <stdlib.h>
using namespace std;
// first name space
namespace first_space {
void func() {
cout << "Inside first_space"
<< endl;
}
// second name space
namespace second_space {
void func() {
cout << "Inside second_space"
<< endl;
}
}
}
Example 6: Nested Namespaces
using namespace first_space::second_space;
int main () {
// This will call function from
// second name space.
func();
system("PAUSE");
return 0;
}
// now try with
// using namespace first_space
Page 1 Page 2