This document provides an overview of key concepts in C++ including classes, objects, encapsulation, inheritance, and pointers. It discusses how classes can be used to model real-world entities, hiding implementation details and exposing only necessary functions. Inheritance allows code reuse by deriving specialized classes from general base classes. Pointers store the address of variables in memory and can be used to pass data between functions by reference. The document also provides an example Student class with member variables and functions to set and retrieve student data like GPA.
This presentation forms part of a tutorial on learning Javascript foundations. It is an introduction to the basic concepts of object oriented programming and using Javascript objects to organise code.
This presentation forms part of a tutorial on learning Javascript foundations. It is an introduction to the basic concepts of object oriented programming and using Javascript objects to organise code.
A class definition consists of two parts: header and body. The class header specifies the class name and its base classes. (The latter relates to derived classes and is discussed in Chapter 8.) The class body defines the class members. Two types of members are supported:
Data members have the syntax of variable definitions and specify the representation of class objects.
Member functions have the syntax of function prototypes and specify the class operations, also called the class interface.
Class members fall under one of three different access permission categories:
Public members are accessible by all class users.
Private members are only accessible by the class members.
Protected members are only accessible by the class members and the members of a derived class.
The data type defined by a class is used in exactly the same way as a built-in type.
Let's make a contract: the art of designing a Java APIMario Fusco
An API is what developers use to achieve some task. More precisely it establishes a contract between them and the designers of the software exposing its services through that API. In this sense we're all API designers: our software doesn't work in isolation, but becomes useful only when it interacts with other software written by other developers. When writing software we're not only consumers, but also providers of one or more API and that's why every developer should know the features of a good API. During this presentation we will go through real-world examples, also taken from the standard Java API, of good and bad API and comment them in order to show the dos and don'ts of API design. More in general we will discuss the characteristics of an easy and pleasant to use API, like consistency, discoverability and understandability, together with some basic concepts like the principle of least astonishment, and find out how to achieve them.
This presentation is about multitasking with std::future.
Presentation by Dmytro Gurin (Lead Software Engineer, GlobalLogic, Kyiv), delivered at GlobalLogic C++ TechTalk in Lviv, September 18, 2014.
More details -
http://www.globallogic.com.ua/press-releases/lviv-cpp-techtalk-coverage
A class definition consists of two parts: header and body. The class header specifies the class name and its base classes. (The latter relates to derived classes and is discussed in Chapter 8.) The class body defines the class members. Two types of members are supported:
Data members have the syntax of variable definitions and specify the representation of class objects.
Member functions have the syntax of function prototypes and specify the class operations, also called the class interface.
Class members fall under one of three different access permission categories:
Public members are accessible by all class users.
Private members are only accessible by the class members.
Protected members are only accessible by the class members and the members of a derived class.
The data type defined by a class is used in exactly the same way as a built-in type.
Let's make a contract: the art of designing a Java APIMario Fusco
An API is what developers use to achieve some task. More precisely it establishes a contract between them and the designers of the software exposing its services through that API. In this sense we're all API designers: our software doesn't work in isolation, but becomes useful only when it interacts with other software written by other developers. When writing software we're not only consumers, but also providers of one or more API and that's why every developer should know the features of a good API. During this presentation we will go through real-world examples, also taken from the standard Java API, of good and bad API and comment them in order to show the dos and don'ts of API design. More in general we will discuss the characteristics of an easy and pleasant to use API, like consistency, discoverability and understandability, together with some basic concepts like the principle of least astonishment, and find out how to achieve them.
This presentation is about multitasking with std::future.
Presentation by Dmytro Gurin (Lead Software Engineer, GlobalLogic, Kyiv), delivered at GlobalLogic C++ TechTalk in Lviv, September 18, 2014.
More details -
http://www.globallogic.com.ua/press-releases/lviv-cpp-techtalk-coverage
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Brief Summary Of C++
1. Brief Summary of C++ (Mainly on Class)
Attributes of OOP
1) Encapsulation
a. Hide the data (make the data variable private) and hide the internal
function that is not needed by the external user
b. Only exposes the functions that are required by the external user. User
calls these public functions in order to use the object.
2) Code reuse
a. Use inheritance to reuse existing code
3) Abstraction
Use class to model the things you have in your program. Program consist of
objects that talk to each other by calling each other public member function.
4) Generalization
a. Use template class or template function to build generic class or function
b. Generic function can process different type of data
c. Build a general class and use it as a base to derive specialized class
(inheritance)
Variable
- Refers to memory location used to store data
- Is given a name example weight, myID . It is not convenient to memorize memory
address e.g A1230000FFA
Variable data type can be classified to a few types
a) Simple data type
int, char , float, double
int weight = 0; // declare and initialize the variable in 1 line
of code.
b) Array
Array is a compound data type whereby it stores a group of data
int weightArray[5] ; // declare an array called weightArray to
store 5 integer type data
int weightArray[5] ; // declare an array called weightArray to
store up to 5 integer type data
int weightArray2[5] = {1,2,3,4,5}; // You can also declare and
initialize
cout << endl << weightArray2[2] ; //% display the 3rd element
c) Pointer
Pointer is a type of variable that is used to represent other variable
It is mainly used to represent an array, object and also to pass data to a function
by reference. In addition the function can pass data to the pointer so that it can be
retrieved by the caller function.
Pointer stores the address of the variable that it points to.
1
2. int* ptr ; // declare a pointer to int and name the pointer as
ptr
int* ptr2 = &weight ; // declare a pointer to int and initialize
it to point to the variable weight in 1 line of code
ptr = &weight2 ; // The previously declared pointer is now
pointed at the variable weight2
cout << endl << *ptr2 << endl ; // display the data in the
variable pointed by ptr2, display 0 since weight=0
Using pointer to represent array
int* arrayPtr;
arrayPtr = weightArray2 ; //arrayPtr now points to the array
// weightArray2
// take note that the array name hold
the address of the array
cout << endl << arrayPtr ; // display the address of the 1st
element
cout << endl << arrayPtr+1 ; // display the address of the 2nd
element
cout << endl << *(arrayPtr) ; // display 1
cout << endl << *(arrayPtr+1) ; // display 2
cout << endl << arrayPtr[0] ; // display 1
cout << endl << arrayPtr[1] ; // display 2
char* mystring = "Hello" ;
cout << mystring;
const int* pt = weightArray ; // pt is a pointer to a constant,
you cannot use pt to change the value of weightArray
// *(pt+1) = 200 ; this is wrong
int* const pt2 = weightArray; // pt2 is a constant pointer, you
cannot use pt2 to point to other variable, pt2 always represents
weightArray // pt2 = weightArray2 , this is wrong
d) Reference
Reference is a variable that represent other variable as an alias.
It is mainly used to pass data to a function by reference. In addition the function
can pass data to the reference variable so that it can be retrieved by the caller
function.
int& rnum = weight2; // declare a reference variable by the name
rnum and initialize it to represent weight2
// reference variable must always
be initialized when it is first declared
cout << endl << rnum ; // display 10, the value of weight2
rnum = weight ; // reassign rnum to represent the variable
weight
cout << endl << rnum ; // display 0, the value of weight
e) Class and Structure
In C++ there are many predefined variable type such as int, char, float
However you can also create your own data type using the class and struct
construct.
2
3. Class is a c++ language construct that is used as a blueprint to create objects
Object is an instance of the class and is a variable.
Object contain member function and member variable. Member function provide
the service and member variable store data.
Member can be private , public, protected
// Declare a class by the name of Student
// the purpose or responsibility of Student class is to store
students information
// To fulfill its responsibility , it provides a set of services
to the user
// User can invoke the public member function for example
getCgpa() to retrieve the cgpa value stored in the object
class Student {
public:
Student(); // default constructor
Student(float p_cgpa) { _cgpa = p_cgpa ;} // parameterized
constructor
Student(string name);
Student(string name, string address);
float getCgpa(); // member function
void set_CgpaAndAge( float p_cgpa, int p_age) {
_cgpa = p_cgpa ;
_age = p_age;
}
void setName(string pName) { _name = pName;}
string getAddress();
void getcgpaAndAge(float& p_cgpa, int& p_age);
private:
string _name;
string _address;
char _icNumber[20];
float _cgpa;
int _age;
} ;
// Test program to test the class and its member function defined above
int main()
{
Student stud1("Lim"); // Create the object called stud1 and
initialize its name
stud1.set_CgpaAndAge(3.99,20); // set the cgpa value and age of
object stud1
}
Getting function to return more than one value
Suppose in the main function we want to retrieve the cgpa and age value of the
object, we cannot write a function to return 2 values. A function can only return 1
value. One way to solve this problem so that a function can pass more than 1
3
4. variable back to the caller function is to use the reference variable as the function
argument.
main( )
{ int x=0, y=0;
functionName(x,y) ;
cout << x << y ; // Display 100 200
}
void functionName (int& arg1, int& arg2)
{
arg1 = 100;
arg2 = 200;
}
This way the function functionName can return the 2 integer values 100, 200 back
to the main function. By using reference variable you can pass multiple data to a
function and also use it as container to store the data that need to be returned by
the function.
Here is the implementation for the Student class member function The main ()
function need to retrieve the cgpa value and the age value from the Student object
stud1.
1) Method 1 : Use a reference variable
// the function below retrieve the data _cgpa and _age from
the Student object and pass them to the reference variable
so that the caller function can get hold of this data
void Student::getcgpaAndAge(float& p_cgpa, int& p_age) {
p_cgpa = _cgpa ;
p_age = _age ; // assign member variable to argument
// variable
}
int main()
{
int age; float cgpa;
Student stud1("Lim"); // Create the object called stud1 and
initialize its name
stud1.set_CgpaAndAge(3.99,20); // set the cgpa value and
age of object stud1
stud1.getcgpaAndAge(cgpa, age); // request the stud1
object to get and return its cgpa value and age value
cout << endl << "cgpa = " << cgpa; // display 3.99
cout << endl << " age = " << age;
}
4
5. Program output
Output of object s4
Ali
Output of object s4 access using pointer
Ali
Output of object s4 access using reference
Ali
Output of object ecpStudents[1]
ecpStudents[1]._name = Ah Kow
Output of object ecpStudents[2] in the array , this time the array is represented using the
pointer pStd
ecpStudents[2]._name = pStd[2]._name = Aminah
Use pointer pStd2 to represent the array of 3 Student objects, access the 2nd object
pStd2[1]._name = No name yet
This program allow the Student object to be added to the Subject object
Subject object has many Student object
Constructor called: Subject Name: ECP4206 OOP Programming
Number of Student are 2
Phua CK
Obama
5