La historia cuenta la vida de Blancanieves, una hermosa niña que sufría los celos de su malvada madrastra, una bruja. La bruja envió a un cazador para matar a Blancanieves, pero él la dejó escapar. Más tarde, la bruja envenenó a Blancanieves con una manzana, haciéndola caer en un profundo sueño, aunque un príncipe la despertó con un beso de amor.
The document discusses Stuart Hall's theory that audiences can interpret media texts in three ways: a preferred reading, where the audience agrees with the message; a negotiated reading, where the audience neither fully agrees nor disagrees; and an oppositional reading, where the audience disagrees with the message. It provides examples of how different people may have a preferred, negotiated, or oppositional reading of images depicting representations of women.
Matthew Hopkinson, Local Data Company - Solocal Group UK Event "How To Drive ...Solocal Group UK
The document discusses trends in the British retail industry based on data from The Local Data Company. It finds that while retail openings exceeded closures from 2009-2012, closures have exceeded openings since 2012. Vacancy rates vary significantly by region, with the highest in the North West of England and lowest in Greater London and the South East. Factors such as access to transportation and a diversity of retail options affect vacancy rates. Overall, the trends suggest a challenging time for many high street retailers as consumers' shopping behaviors continue to shift online and to large retail centers.
Nancy Jean Cates passed away on December 2, 2013 at the age of 62. She lived in California and was survived by her husband, two children, and three grandchildren. Nancy will be fondly remembered and deeply missed by her loving family and friends.
Bab 4 membahas tentang organisasi layanan informasi dan perkembangan strukturnya dari tersentralisasi menjadi lebih terdesentralisasi serta model-model organisasi informasi yang inovatif seperti model sekutu, model platform, dan model terskala. Komputasi pengguna akhir dan pengguna sebagai sumber daya informasi penting juga dibahas beserta manfaat dan risikonya.
The document provides instructions for students to recap key narrative theories, create their own examples, analyze their own work using the theories, and post definitions, a storyboard illustrating each theory with creative camera work, and examples from their own work applying the theories to blogs. Students are also asked to review and analyze a high level response on applying the theories and give reasons for thinking it is high level.
Dokumen ini membahas tentang proyek membuat query basis data menggunakan Microsoft Access. Proyek ini menggunakan basis data teksbook yang berisi data mahasiswa dan nilai mata kuliah. Dokumen ini menjelaskan cara membuat query dengan memberikan batasan nilai tertentu seperti kurang dari 60, lebih dari 60, antara 60 hingga 75, dan lainnya. Diberikan juga contoh gambar hasil query dan laporan yang dihasilkan.
Este documento trata sobre la violencia contra la mujer y la necesidad de romper el silencio. Más de 600,000 mujeres sufren maltrato en el país cada año y menos de la cuarta parte deciden denunciarlo. Se enfatiza la importancia de la sensibilización social, romper estereotipos, y ofrecer nuevas opciones a las mujeres maltratadas como buscar empleo o recursos tecnológicos.
Jamie A Cowan, Timendo - Solocal Group UK Event "How To Drive Online Traffic ...Solocal Group UK
The document describes an online appointment booking solution called Timendo. It discusses how the solution allows businesses to convert more website visitors into sales by enabling visitors to directly book appointments online anytime, even outside of business hours. Key features highlighted include appointment confirmations by email and SMS, reminders, and a reported 80% reduction in no-shows. The company claims it has booked over 32 million appointments to date across 1 million users. Implementation and customer support services are also summarized.
The document provides instructions for students to choose between creating a video game cover and ads or a magazine cover and spread. Students must research 2 genres within their choice and find examples of similar existing products. The research should answer questions about the titles, target audiences, and how the genres are conveyed. Sample answers are provided about fashion magazine and video game titles that were researched.
The document describes different camera shots and angles used in a scene, including a mid shot of Adler with a large depth of field, a close-up, and alternating shots from a high to low camera angle between two subjects. Opulent surroundings and cream upholstery provide the setting for the scene.
David Lee Cates lived from February 9, 1981 to September 26, 2014. He passed away at the age of 33. This brief obituary provides the name and dates of birth and death for David Lee Cates.
Andrew Mc Clelland, IMRG - Solocal Group UK Event "How To Drive Online Traffi...Solocal Group UK
Online retail sales in the UK grew 18% in December 2013 compared to the previous year, with total online spending reaching £11.1 billion. Mobile retail also saw very strong growth, with sales via smartphones and tablets up 186% and 292% respectively year-over-year. The document also notes that over two-thirds of UK consumers now own a smartphone, and many use their phones to research products while shopping in physical stores. Multichannel retailers saw 16-17% growth compared to 25% for pure online retailers.
1) The document discusses how video has increased traffic and revenue for a news organization called Appledaily over the past 5 years.
2) Some types of videos that performed best included exclusive news stories, positive news, mini-series, entertainment, science/gadgets, and funny videos.
3) The organization found that decentralizing video production across departments and producing video content beyond just reprinted newspaper articles helped drive more traffic and ads revenue.
The document discusses the evolution of online communities from bulletin board systems (BBS) to modern social networks and introduces a new model of Integrated Mobile Communities (IMC). IMC aims to integrate existing mobile communities like e-commerce, entertainment, special interest groups into a unified platform to better serve mobile users.
This document provides instructions for students to complete a controlled assessment production portfolio worth 30% of their overall media studies mark. It outlines the components of the portfolio, which include a production log, the media product itself, an evaluation, and appendix. Students are guided through research, design, photography, and production stages to create a video game cover and advertisements. They are advised to thoroughly research conventions and conduct market research to make their final product as professional as industry standard. All stages must be properly logged and completed by various deadlines.
Collective identity refers to an individual's sense of belonging to a group and is an important part of personal identity. Film portrayals can help people gain a sense of belonging and identity beyond themselves by participating in watching films that depict certain social groups. Quadrophenia (1979) directed by Franc Roddam depicts British youth subcultures in the 1960s to both entertain audiences and represent these subcultures that redefined society.
La historia cuenta la vida de Blancanieves, una hermosa niña que sufría los celos de su malvada madrastra, una bruja. La bruja envió a un cazador para matar a Blancanieves, pero él la dejó escapar. Más tarde, la bruja envenenó a Blancanieves con una manzana, haciéndola caer en un profundo sueño, aunque un príncipe la despertó con un beso de amor.
The document discusses Stuart Hall's theory that audiences can interpret media texts in three ways: a preferred reading, where the audience agrees with the message; a negotiated reading, where the audience neither fully agrees nor disagrees; and an oppositional reading, where the audience disagrees with the message. It provides examples of how different people may have a preferred, negotiated, or oppositional reading of images depicting representations of women.
Matthew Hopkinson, Local Data Company - Solocal Group UK Event "How To Drive ...Solocal Group UK
The document discusses trends in the British retail industry based on data from The Local Data Company. It finds that while retail openings exceeded closures from 2009-2012, closures have exceeded openings since 2012. Vacancy rates vary significantly by region, with the highest in the North West of England and lowest in Greater London and the South East. Factors such as access to transportation and a diversity of retail options affect vacancy rates. Overall, the trends suggest a challenging time for many high street retailers as consumers' shopping behaviors continue to shift online and to large retail centers.
Nancy Jean Cates passed away on December 2, 2013 at the age of 62. She lived in California and was survived by her husband, two children, and three grandchildren. Nancy will be fondly remembered and deeply missed by her loving family and friends.
Bab 4 membahas tentang organisasi layanan informasi dan perkembangan strukturnya dari tersentralisasi menjadi lebih terdesentralisasi serta model-model organisasi informasi yang inovatif seperti model sekutu, model platform, dan model terskala. Komputasi pengguna akhir dan pengguna sebagai sumber daya informasi penting juga dibahas beserta manfaat dan risikonya.
The document provides instructions for students to recap key narrative theories, create their own examples, analyze their own work using the theories, and post definitions, a storyboard illustrating each theory with creative camera work, and examples from their own work applying the theories to blogs. Students are also asked to review and analyze a high level response on applying the theories and give reasons for thinking it is high level.
Dokumen ini membahas tentang proyek membuat query basis data menggunakan Microsoft Access. Proyek ini menggunakan basis data teksbook yang berisi data mahasiswa dan nilai mata kuliah. Dokumen ini menjelaskan cara membuat query dengan memberikan batasan nilai tertentu seperti kurang dari 60, lebih dari 60, antara 60 hingga 75, dan lainnya. Diberikan juga contoh gambar hasil query dan laporan yang dihasilkan.
Este documento trata sobre la violencia contra la mujer y la necesidad de romper el silencio. Más de 600,000 mujeres sufren maltrato en el país cada año y menos de la cuarta parte deciden denunciarlo. Se enfatiza la importancia de la sensibilización social, romper estereotipos, y ofrecer nuevas opciones a las mujeres maltratadas como buscar empleo o recursos tecnológicos.
Jamie A Cowan, Timendo - Solocal Group UK Event "How To Drive Online Traffic ...Solocal Group UK
The document describes an online appointment booking solution called Timendo. It discusses how the solution allows businesses to convert more website visitors into sales by enabling visitors to directly book appointments online anytime, even outside of business hours. Key features highlighted include appointment confirmations by email and SMS, reminders, and a reported 80% reduction in no-shows. The company claims it has booked over 32 million appointments to date across 1 million users. Implementation and customer support services are also summarized.
The document provides instructions for students to choose between creating a video game cover and ads or a magazine cover and spread. Students must research 2 genres within their choice and find examples of similar existing products. The research should answer questions about the titles, target audiences, and how the genres are conveyed. Sample answers are provided about fashion magazine and video game titles that were researched.
The document describes different camera shots and angles used in a scene, including a mid shot of Adler with a large depth of field, a close-up, and alternating shots from a high to low camera angle between two subjects. Opulent surroundings and cream upholstery provide the setting for the scene.
David Lee Cates lived from February 9, 1981 to September 26, 2014. He passed away at the age of 33. This brief obituary provides the name and dates of birth and death for David Lee Cates.
Andrew Mc Clelland, IMRG - Solocal Group UK Event "How To Drive Online Traffi...Solocal Group UK
Online retail sales in the UK grew 18% in December 2013 compared to the previous year, with total online spending reaching £11.1 billion. Mobile retail also saw very strong growth, with sales via smartphones and tablets up 186% and 292% respectively year-over-year. The document also notes that over two-thirds of UK consumers now own a smartphone, and many use their phones to research products while shopping in physical stores. Multichannel retailers saw 16-17% growth compared to 25% for pure online retailers.
1) The document discusses how video has increased traffic and revenue for a news organization called Appledaily over the past 5 years.
2) Some types of videos that performed best included exclusive news stories, positive news, mini-series, entertainment, science/gadgets, and funny videos.
3) The organization found that decentralizing video production across departments and producing video content beyond just reprinted newspaper articles helped drive more traffic and ads revenue.
The document discusses the evolution of online communities from bulletin board systems (BBS) to modern social networks and introduces a new model of Integrated Mobile Communities (IMC). IMC aims to integrate existing mobile communities like e-commerce, entertainment, special interest groups into a unified platform to better serve mobile users.
This document provides instructions for students to complete a controlled assessment production portfolio worth 30% of their overall media studies mark. It outlines the components of the portfolio, which include a production log, the media product itself, an evaluation, and appendix. Students are guided through research, design, photography, and production stages to create a video game cover and advertisements. They are advised to thoroughly research conventions and conduct market research to make their final product as professional as industry standard. All stages must be properly logged and completed by various deadlines.
Collective identity refers to an individual's sense of belonging to a group and is an important part of personal identity. Film portrayals can help people gain a sense of belonging and identity beyond themselves by participating in watching films that depict certain social groups. Quadrophenia (1979) directed by Franc Roddam depicts British youth subcultures in the 1960s to both entertain audiences and represent these subcultures that redefined society.
4. Izņēmumu apstrāde
Izņēmums – nestandarta gadījums (mainīgo
vērtības), kuru nevar apstrādāt vienotā veidā ar
standarta gadījumiem
izdrukāt divu skaitļu dalījumu
standarta gadījums – cout << x/y;
izņēmums – ko darīt, ja y vienāds ar nulli?
Izņēmumu apstrāde ir mehānisms, ar kura palīdzību
iespējams programmā loģiski atdalīt kļūdu
apstrādes bloku no pārējā koda
Izņēmuma gadījuma apstrādes shēma
izņēmuma konstatēšana un izmešana
izmesta izņēmuma pārtveršana (noķeršana) un apstrāde
5. Izdrukāt divu skaitļu dalījumu!
int main() {
int x,y;
Saucējs nedrīkst būt nulle!
cin >> x >> y;
cout << x/y << endl;
cout << "Dalījums izdrukāts!n";
}
6. Izdrukāt divu skaitļu dalījumu!
int main() {
int x,y;
cin >> x >> y;
if (y==0) cout << "Kļūda!n";
else {
cout << x/y << endl;
cout << "Dalījums izdrukāts!n";
}
}
7. Izsaukt funkciju, kas izdrukā divu skaitļu
dalījumu
void f(int x, int y) {
if (y==0) cout << "Kļūda!n";
else cout << x/y << endl;
}
int main() {
int x,y;
Var gadīties, ka dalījums nav izdrukāts
cin >> x >> y;
f(x,y);
cout << "Dalījums izdrukāts!n";
}
8. Izsaukt funkciju, kas izdrukā divu skaitļu
dalījumu
bool f(int x, int y) {
if (y==0) {
cout << "Kļūda!n";
return false;
}
else {
cout << x/y << endl;
return true;
}
}
Funkcija f atgriež true vai
false, atkarībā no tā, vai
dalīšana ir izdevusies vai nav
Funkcija f kļūst sarežģītāka..
int main() {
int x,y;
cin >> x >> y;
if (f(x,y)) cout << "Dalījums izdrukāts!n";
}
9. Izsaukt funkciju, kas atgriež divu skaitļu
dalījumu
int f(int x, int y) {
if (y==0) {
cout << "Kļūda!n";
return 0;
}
else return x/y;
}
Ja x=5 un y=0, tad izdrukā:
Kļūda!
0
Dalījums izdrukāts!
main funkcija nezin, vai
int main() {
funkcijā f notikusi kļūda vai nē
int x,y;
cin >> x >> y;
cout << f(x,y) << endl;
cout << "Dalījums izdrukāts!n";
}
10. Izsaukt funkciju, kas atgriež divu skaitļu
dalījumu
int f(int x, int y, bool & isError) {
if (y==0) {
isError = true;
return 0;
}
else {
isError = false;
return x/y;
}
}
int main() {
int x,y;
bool b;
cin >> x >> y;
int res = f(x,y,b);
if (!b) {
cout << res << endl;
cout << "Dalījums izdrukāts!n";
}
else cout << "Kļūda!n";
}
Funkcijas f un main
kļūst sarežģītākas..
11. Izsaukt funkciju, kas atgriež divu skaitļu
dalījumu
int f(int x, int y) {
if (y==0) throw "Kļūda!";
return x/y;
}
int main() {
int x,y;
cin >> x >> y;
try {
int res = f(x,y);
cout << res << endl;
cout << "Dalījums izdrukāts!n";
}
catch (const char * errorMsg) {
cout << errorMsg << endl;
}
}
12. Izņēmumu apstrādes pamatshēma
try bloks
bloks, kurā raksta darbības, kas varētu radīt izņēmuma situācijas
ja šajā blokā tiek izpildīta komanda throw, vadība tiek nodota
"atbilstošajam" catch blokam
catch bloks
bloks, kurā notiek radušās izņēmuma situācijas apstrāde (parasti –
paziņojuma izvadīšana lietotājam)
catch blokam ir viens parametrs – tātad komandai throw var pierakstīt
vienu argumentu
atbilstošā catch bloka piemeklēšana notiek, balstoties uz šī parametra tipu
catch parametram jābūt ar tādu pat tipu kā throw argumentam
vienam try blokam var būt vairāki catch bloki, kas savā starpā atšķiras ar
parametra tipiem
catch (const char * errorMsg) throw "Kļūda!";
catch (int errorNum) throw 17;
catch (...) ja throw argumenta tips neatbilst nevienam citam catch
blokam
13. Izņēmumu apstrādes piemērs
Ja y=0:
void f(int x, int y) {
if (y==0) throw "Kļūda";
cout << "Dalījums: " << x/y << endl;
if (x > 100000) throw x;
if (y > 100000) throw y;
if (x==17 || y==17) throw 'E';
cout << "Reizinājums: " << x*y << endl;
}
- tiek izmests izņēmums ar argumentu
"Kļūda"
- tiek noskaidrots argumenta tips: char *
- funkcijā f throw nav iekš try bloka
- tiek beigts darbs ar funkciju f
int main() {
int x,y;
cin >> x >> y;
try {
f(x,y);
}
catch (const char * errorMsg) {
cout << errorMsg << endl;
}
catch (int bigNumber) {
cout << "Pārāk liels reizinātājs - " << bigNumber << endl;
}
catch (...) {
cout << "Ar 17 man reizināt nepatīk!n" << endl;
}
}
- funkcijā main tiek meklēts catch bloks
ar parametra tipu char *
- tiek izpildītas catch bloka darbības
- tiek pāriets uz nākamo darbību aiz
visiem catch blokiem
14. Izņēmumu apstrādes piemērs
Ja x=123456:
- tiek izmests izņēmums ar argumentu x
void f(int x, int y) {
if (y==0) throw "Kļūda";
cout << "Dalījums: " << x/y << endl;
if (x > 100000) throw x;
if (y > 100000) throw y;
if (x==17 || y==17) throw 'E';
cout << "Reizinājums: " << x*y << endl;
}
- tiek noskaidrots argumenta tips: int
- funkcijā f throw nav iekš try bloka
- tiek beigts darbs ar funkciju f
- funkcijā main tiek meklēts catch bloks
ar parametra tipu int
int main() {
int x,y;
cin >> x >> y;
try {
f(x,y);
}
catch (const char * errorMsg) {
cout << errorMsg << endl;
}
catch (int bigNumber) {
cout << "Pārāk liels reizinātājs - " << bigNumber << endl;
}
catch (...) {
cout << "Ar 17 man reizināt nepatīk!n" << endl;
}
}
- tiek izpildītas catch bloka darbības
- tiek pāriets uz nākamo darbību aiz
visiem catch blokiem
15. Izņēmumu apstrādes piemērs
Ja x=17:
- tiek izmests izņēmums ar argumentu 'E'
void f(int x, int y) {
if (y==0) throw "Kļūda";
cout << "Dalījums: " << x/y << endl;
if (x > 100000) throw x;
if (y > 100000) throw y;
if (x==17 || y==17) throw 'E';
cout << "Reizinājums: " << x*y << endl;
}
- tiek noskaidrots argumenta tips: char
- funkcijā f throw nav iekš try bloka
- tiek beigts darbs ar funkciju f
- funkcijā main tiek meklēts catch bloks
ar parametra tipu char
int main() {
int x,y;
cin >> x >> y;
try {
f(x,y);
}
catch (const char * errorMsg) {
cout << errorMsg << endl;
}
catch (int bigNumber) {
cout << "Pārāk liels reizinātājs - " << bigNumber << endl;
}
catch (...) {
cout << "Ar 17 man reizināt nepatīk!n" << endl;
}
}
- tāds catch bloks neeksistē, tiek
meklēts catch bloks ar argumentu (...)
- tiek izpildītas catch bloka darbības
- tiek pāriets uz nākamo darbību aiz
visiem catch blokiem
16. throw darbības shēma
Sastopot try bloka sākumu, tiek izpildītas pēc kārtas try bloka komandas
Sastopot throw komandu, vadība tiek nodota atbilstošajam catch
blokam
ja throw komanda neatrodas try blokā, funkcija tiek pārtraukta un vadība tiek
nodota izsaucošajai funkcijai
ja throw komanda atrodas try blokā
ja izsaucošajā funkcijā minētās funkcijas izsaukums atrodas try blokā, vadība tiek
nodota šīs funkcijas atbilstošajam catch blokam
ja šīs funkcijas izsaukums neatrodas try blokā, funkcija tiek pārtraukta un vadība
tiek nodota izsaucošajai funkcijai utt.
ja eksistē catch bloks ar tādu parametra tipu, kādu pieprasa throw komanda,
vadība tiek nodota šim catch blokam
ja šāds catch bloks neeksistē, vadība tiek nodota blokam catch(...)
ja neeksistē arī bloks catch(...), funkcija tiek pārtraukta un vadība tiek nodota
izsaucošajai funkcijai
Ja vadība nodota catch blokam, tiek izpildītas visas šī bloka komandas
pēc kārtas un pēc tam vadība tiek nodota komandai, kas atrodas aiz
visiem aktuālā try bloka atbilstošajiem catch blokiem
18. Nosaukumu telpas
Nosaukumu telpas ir speciāls mainīgo, funkciju un citu programmas
elementu redzamības veids
Programmas elementu redzamības veidi
funkcijas lokālie elementi – visizplatītākais veids
globālie elementi – definēti ārpus funkcijām, izmantojumi no jebkuras vietas
programmā
klases elementi
nosaukumu telpas elementi – globālo elementu šaurāks gadījums
privātie – redzami tikai klases robežās
aizsargātie – redzami tikai pašas klases un tās visu apakšklašu robežās
globālā elementu telpa (visa programma) tiek sadalīta mazākās daļās
Nosaukumu telpu nepieciešamības pamatojums
nevar izveidot divas globālas (parastas) funkcijas ar vienādiem vārdiem un
vienādu parametru sarakstu
ja vajag dažādas funkcijas ar vienādiem vārdiem, katru no tām var ielikt savā
nosaukumu telpā
dažādiem programmētājiem netiek aizliegts veidot tādas funkcijas, kādas paši vēlas
dažādu programmētāju rakstītās funkcijas vienmēr var salikt kopā vienā projektā
19. Vairāki programmētāji vienā projektā
Programmētājs A
void sum(int x, int y) {
cout << x+y << endl;
}
Programmētājs B
int sum(int a, int b) {
return a+b;
}
Šīs divas funkcijas pa tiešo nevar iekļaut vienā projektā
sum(17,5); nav skaidrs, kuru funkciju saukt
Risinājuma varianti
kādu no tām var pārsaukt citā vārdā
katru no tām var iekļaut savā redzamības apgabalā (nosaukumu
telpā)
21. Piekļūšana nosaukumu telpas elementiem
namespace mySpace {
int x;
void f(int x) {cout << x << x*x;}
}
int main() {
mySpace::x = 17;
mySpace::f(mySpace::x); //17289
}
22. Vairāki programmētāji vienā projektā
namespace A {
void sum(int x, int y) {
cout << x+y << endl;
}
}
namespace B {
int sum(int a, int b) {
return a+b;
}
}
int main() {
A::sum(17,5);
cout << B::sum(17,5);
}
23. Nosaukumu telpas iekļaušana programmā
namespace mySpace {
int x;
void f(int x) {cout << x << x*x;}
}
using namespace mySpace;
int main() {
x = 17;
f(x);
}
mySpace elementiem iespējams pa taisno
piekļūt tā bloka ietvaros, kurā veikts
nosaukumu telpas iekļāvums
24. Nosaukumu telpas iekļaušana programmā
namespace A {
void sum(int x, int y) {
cout << x+y << endl;
}
}
namespace B {
int sum(int a, int b) {
return a+b;
}
}
using namespace A;
using namespace B;
int main() {
Nav skaidrs, kuru funkciju no
sum(17,5);
kuras telpas saukt, jo abas
cout << sum(17,5);
telpas šajā vietā ir redzamas
}
25. Nosaukumu telpa std
Nosaukumu telpa std definēta bibliotēkā <iostream>
Nosaukumu telpā std definēti vairāki elementi
objekti cin un cout
konstante endl
datu tips string
...
Kā piekļūt std elementiem
using namespace std;
...
cout << x << endl;
std::cout << x << std::endl;
26. Nosaukumu telpu veidošanas specifika
Vienu nosaukumu telpu drīkst veidot pa vairākām
daļām
namespace mySpace {
int x;
void f(int x) {cout << x << x*x;}
}
...
namespace mySpace {
int y;
}
Sekas – jebkurš drīkst pievienot jaunus elementus
jebkurai nosaukumu telpai
namespace std {
void f() {...}
}
27. Nosaukumu telpu piemērs
#include <iostream>
namespace mySpace {
int cout(int a, int b) {return a+b;}
}
int main() {
int x,y;
{
using namespace std;
cin >> x >> y;
cout << x << "+" << y << "=";
} //Šajā vietā beidzas nosaukumu telpas std redzamība
using namespace mySpace;
std::cout << cout(x,y) << std::endl;
}
29. Norādes uz funkcijām
Mainīgo veidi C++
dati
int x; double y; char s[20]; string s1;
person p;
norādes uz datiem
int * x; char * s; person * p;
norādes uz funkcijām
Ja mainīgais deklarēts kā norāde uz funkciju, tad
mainīgajam kā vērtību var piešķirt kādas funkcijas
adresi
šo funkciju var izsaukt, nerakstot pa tiešo funkcijas vārdu,
bet tā vietā izsaucot to caur norādi (mainīgo)
30. Norādes uz funkciju deklarēšana
<return_type> (* fp) (<paramTypeList>);
tiek deklarēts mainīgais fp, kas būs norāde uz tādām funkcijām, kurām ir
tādi parametru tipi, kā norādīts iekš <paramTypeList> un kuru
atgriežamais tips ir <return_type>
int (* p) (int, int);
p – norāde uz int tipa funkcijām ar diviem int tipa parametriem
char * (* cp) (char *, int, char *);
cp – norāde uz char * tipa funkcijām ar trim parametriem – simbolu virkni,
veselu skaitli un simbolu virkni
Saīsinātais pieraksts, izmantojot tipu pārsaukšanas operatoru
typedef int (* intPtr) (int, int);
izveidot jaunu tipu ar nosaukumu intPtr un pasludināt to par tipu norādēm uz
int tipa funkcijām ar diviem int tipa parametriem
intPtr p;
p – mainīgais, kas ir norāde uz int tipa funkcijām ar diviem int tipa parametriem
31. Funkcijas piesaistīšana norādei uz funkciju
un funkcijas izsaukšana caur norādi
Norādes uz datiem
int x = 17;
int * p;
p = &x;
cout << *p;
Norādes uz funkcijām
int add(int x, int y) {return x+y;}
int (*p) (int, int); //Deklarējam p kā norādi uz funkciju
p = &add; //Liekam p norādīt uz konkrētu funkciju add
cout << (*p)(17,5); //Izsaucam funkciju add caur norādi
Jaunajā C++ standartā drīkst arī šādi
int add(int x, int y) {return x+y;}
int (*p) (int, int);
p = add;
cout << p(17,5);
32. Norāžu uz funkcijām piemērs
#include <iostream>
using namespace std;
int main() {
int x,y;
cin >> x >> y;
int add(int a, int b) {
int (* p1) (int, int);
return a+b;
p1 = add;
}
cout << p1(x,y) << endl;
intPtr p2 = multiply;
int multiply(int a, int b) {
cout << p2(x,y) << endl;
return a*b;
cout << compute(p1,x,y)<<endl;
}
cout << compute(p2,x,y)<<endl;
intPtr funcArr[2];
typedef int (*intPtr) (int,int);
funcArr[0] = add;
funcArr[1] = multiply;
int compute(intPtr p, int a, int b) { for (int i=0; i<2; i++)
return p(a,b);
cout <<compute(funcArr[i],x,y)<<endl;
}
system("Pause");
return 0;
}
33. Uzdevums 1
Dotas divas funkcijas
char * toUpper(char * s) {...}
char * toLower(char * s) {...}
pārvērš visus burtus dotajā virknē par lielajiem burtiem
pārvērš visus burtus dotajā virknē par mazajiem burtiem
Uzrakstīt funkciju, kurai var padot simbolu virkni un
norādi uz kādu no augstākminētajām funkcijām
funkcijai jāatgriež dotā simbolu virkne, kas pārveidota
atbilstoši norādītajai funkcijai
35. Komandrindas argumenti
Izsaucot programmu no komandrindas
D:MyFolder>myProgram.exe
D:MyFolder>myProgram
tiek izsaukta funkcija main()
D:MyFolder>copy file1 file2
tiek izsaukta funkcija main()
copy – programmas nosaukums
file1, file2 – programmai nododamie argumenti
D:MyFolder>myProgram param1 param2 param3
tiek izsaukta funkcija main()
kas notiek ar trim padotajiem argumentiem???
argumenti tiek ignorēti...
Funkciju main valodā C++ iespējams uzrakstīt divos veidos
ignorējot saņemtos argumentus
ņemot pretī patvaļīgu argumentu sarakstu
36. Funkcijas main parametri
int main(int argc, char ** argv) {...}
argc – funkcijai padoto argumentu skaits
argv – funkcijai padoto argumentu saraksts
arī pašas programmas vārds tiek uzskatīts par vienu no
argumentiem, tātad jebkurā gadījumā argc>0
argv – masīvs (garumā argc) no simbolu virknēm
katrs masīva elements – viens arguments
masīva nulltais elements – programmas vārds
Funkcijā main abi parametri var tikt izmantoti
analoģiski jebkuras citas funkcijas parametriem
37. Komandrindas argumentu piemērs –
Demo
Uzdevums – izveidot programmu, kas darbojas
dažādi atkarīgā no padotajiem argumentiem
0 argumenti – izdrukāt programmas vārdu
1 arguments – nedarīt neko
2 argumenti – izdrukāt abu argumentu summu
3 argumenti
ja 1. arguments ir "+" vai "x", izdrukāt 2. un 3. argumenta
attiecīgi summu vai reizinājumu
ja 1. arguments ir citāds, izdrukāt kļūdas paziņojumu
vairāk par 3 argumentiem – izdrukāt programmas vārdu un
visu argumentu sarakstu
38. Komandrindas argumentu piemērs –
Demo
int main(int argc, char ** argv) {
if (argc==1) {
cout << "Program name: " << argv[0];
return 0;
}
if (argc==2) {
cout << "Nothing to do - only one argument
provided..";
Funkcija atoi pārvērš simbolu
return 0;
virkni par veselu skaitli
}
if (argc==3) {
cout << "Sum: " << add(atoi(argv[1]),atoi(argv[2]));
}
...
39. Komandrindas argumentu piemērs –
Demo
...
if (argc==4) {
string s="";
intPtr p;
if (strcmp(argv[1], "+") == 0) {
s = "Sum: ";
p = add;
}
else
if (strcmp(argv[1], "x") == 0) {
s = "Multiplicity: ";
p = multiply;
}
else {
cout << "Invalid operation: " << argv[1];
return 0;
}
if (s!="") cout << s << compute(p, atoi(argv[2]), atoi(argv[3]));
return 0;
}
...
41. Komandrindas argumentu piemērs –
Demo
int add(int a, int b) {
return a+b;
}
int multiply(int a, int b) {
return a*b;
}
typedef int (*intPtr) (int,int);
int compute(intPtr p, int a, int b) {
return p(a,b);
}
42. Uzdevums 2
Izdrukāt programmai padotos argumentus
alfabētiskā secībā
drīkst pieņemt, ka argumenti sastāv tikai no latīņu
alfabēta burtiem
drīkst pieņemt, ka katrs argumenta (simbolu
virknes) garums būs īsāks par 100 simboliem
D:MyFolder>myProgram abc Cb E Ba ca e
abc, Ba, ca, Cb, E, e