Jump to content

Jyllands-Posten Muhammad cartoons controversy: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Chobot (talk | contribs)
No edit summary
Line 1: Line 1:
Classes (I) Published by Juan Soulie
<!--
Last update on May 7, 2007 at 9:30am
NOTE ABOUT THE IMAGE:
For many days, discussions occurred and polls were conducted on this article's talk pages. In February 2006 the super majority (over 80% of contributing editors) decision was to keep the image displayed as it currently is without a "linkimage" and with no added warning template or text. Thus based upon this, unilateral (without general consensus) removal, hiding, relocation or resizing of this image (particularly in a repetitive fashion) will be considered disruptive editing, detrimental to Wikipedia, and may result in a block of your account and/or IP address.
A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions.
An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.


Classes are generally declared using the keyword class, with the following format:
Additionally, polls were taken regarding adding image warnings to this article with the polls deciding that like the rest of Wikipedia's articles, no warning shall be added to this one. If you wish to discuss aspects of the display of the image of the cartoons, please do so in a civil manner by posting in the image discussion area of this article:
http://en.wikipedia.org/wiki/Talk:Jyllands-Posten_Muhammad_cartoons_controversy/Arguments/Image-Display


Do not unilaterally remove images or add image warnings. Thanks!


class class_name {
If you wish to hide the image of the cartoons on this article, follow these steps:
access_specifier_1:
* Create an account
member1;
* Go to the page http://en.wikipedia.org/wiki/Special:Mypage/monobook.css?action=edit
access_specifier_2:
* Add #mi{display: none;}
member2;
...
} object_names;
Where class_name is a valid identifier for the class, object_names is an optional list of names for objects of this class. The body of the declaration can contain members, that can be either data or function declarations, and optionally access specifiers.


All is very similar to the declaration on data structures, except that we can now include also functions and members, but also this new thing called access specifier. An access specifier is one of the following three keywords: private, public or protected. These specifiers modify the access rights that the members following them acquire:
Afterwards the image will not show. Following these steps does not edit the article itself, just how it is presented to you personally. However there is a slight risk of disrupting your browser's presentation of other articles which contain similar code. Further details available on the above Image-Display Talk Page.


--><span id="mi">[[Image:Jyllands-Posten-pg3-article-in-Sept-30-2005-edition-of-KulturWeekend-entitled-Muhammeds-ansigt.png|250px|thumbnail|The controversial cartoons of Muhammad, as they were first published in ''[[Jyllands-Posten]]'' in September 2005. <!--[http://blog.newspaperindex.com/2005/12/10/un-to-investigate-jyllands-posten-racism/ Larger] older blurry English translated images link-->[http://www.aina.org/releases/20060201143237.htm Larger versions] of the cartoons (some translated into English) are available off-site. The headline, "Muhammeds ansigt", means "Muhammad's face" in English.]]</span>


private members of a class are accessible only from within other members of the same class or from their friends.
The '''''Jyllands-Posten'' Muhammad cartoons controversy''' began after twelve [[editorial cartoon]]s, most of which depicted the Islamic prophet [[Muhammad]], were published in the [[Denmark|Danish]] newspaper ''[[Jyllands-Posten]]'' on [[2005-09-30]]. The newspaper announced that this publication was an attempt to contribute to the debate regarding [[criticism of Islam]] and [[self-censorship]].
protected members are accessible from members of their same class and from their friends, but also from members of their derived classes.
Finally, public members are accessible from anywhere where the object is visible.
By default, all members of a class declared with the class keyword have private access for all its members. Therefore, any member that is declared before one other class specifier automatically has private access. For example:


class CRectangle {
Danish Muslim organizations, who objected to the depictions, responded by holding public protests attempting to raise awareness of ''Jyllands-Posten''&#039;s publication. The [[controversy]] deepened when further examples of the cartoons were [[List of newspapers that reprinted Jyllands-Posten's Muhammad cartoons|reprinted in newspapers]] in more than fifty other countries.
int x, y;
public:
void set_values (int,int);
int area (void);
} rect;


This led to protests across the Muslim world, some of which escalated into violence (more than 100 deaths, altogether)<ref>{{cite news|date=[[2006-03-02]]| title=Cartoon Body Count|publisher=Web|url=http://web.archive.org/web/20060326071135/http://www.cartoonbodycount.com/}}</ref>, including setting fire to the Norwegian and Danish Embassies in Syria, and the storming of European buildings and [[Flag desecration|desecration]] of the [[Flag of Denmark|Danish]] and [[Flag of Germany|German]] flags in [[Gaza City]]. While a number of Muslim leaders called for protesters to remain peaceful, other radical Muslim leaders across the globe, including [[Mahmoud al-Zahar]] of [[Hamas]], issued death threats.<ref>{{Cite web
|url=http://www.spiegel.de/international/0,1518,399177,00.html
|title=Arson and Death Threats as Muhammad Caricature Controversy Escalates
|date=2006-02-04
|publisher=Spiegel online
|accessdate=2007-04-26}}</ref><ref>{{Cite web
|url=http://www.cnn.com/2006/WORLD/meast/02/04/syria.cartoon/
|title=Embassies torched in cartoon fury
|date=2006-02-05
|publisher=CNN.com
|accessdate=2007-04-26}}</ref> Groups, primarily in the western world counter-responded with support of the Danish policies, including "Buy Danish" campaigns and other displays of support for free speech in Denmark.


Declares a class (i.e., a type) called CRectangle and an object (i.e., a variable) of this class called rect. This class contains four members: two data members of type int (member x and member y) with private access (because private is the default access level) and two member functions with public access: set_values() and area(), of which for now we have only included their declaration, not their definition.
Some critics of the cartoons described them as [[Islamophobia|Islamophobic]] or [[racist]],<ref> [http://www.washingtonpost.com/wp-dyn/content/article/2006/01/30/AR2006013001316.html Cartoons of Prophet Met With Outrage] ''Washington Post.'' "Kuwait called the cartoons "despicable racism."<br>° [http://www.iran-daily.com/1384/2497/html/art.htm Blasphemous Cartoons Trigger Muslim Fury] ''Iran Daily''. "Although Jyllands-Posten maintains that the drawings were an exercise in free speech, many consider them as provocative, racist and Islamophobic"<br>° [http://news.bbc.co.uk/1/hi/world/middle_east/4688602.stm Muslim cartoon row timeline] ''BBC online'' "Egyptian newspaper al-Fagr reprints some of the cartoons, describing them as a "continuing insult" and a "racist bomb". </ref> and argue that they are [[Blasphemy|blasphemous]] to people of the Muslim faith, intended to humiliate a Danish minority, or are a manifestation of ignorance about the history of [[Western world|western]] [[imperialism]], from [[colonialism]] to the current [[List of conflicts in the Middle East|conflicts in the Middle East]].<ref>{{cite news|date=[[2006-03-23]]|title=Islam and globanalisation |publisher=Al Ahram|url=http://weekly.ahram.org.eg/2006/787/cu4.htm}}</ref>


Notice the difference between the class name and the object name: In the previous example, CRectangle was the class name (i.e., the type), whereas rect was an object of type CRectangle. It is the same relationship int and a have in the following declaration:
Supporters said that the cartoons have illustrated an important issue in a period of [[Islamist terrorism]] and that their publication is a legitimate exercise of the right of [[free speech]]. They also claim that similar cartoons about other [[religion]]s are frequently printed, arguing that the followers of [[Islam]] were not targeted in a [[Discrimination|discriminatory]] way.<ref>{{cite news|date=[[2006-02-09]]|title=The limits to free speech - Cartoon wars |publisher=The Economist|url=http://www.economist.com/opinion/displaystory.cfm?story_id=5494602}}</ref>


int a;
[[Prime Minister of Denmark|Danish Prime Minister]] [[Anders Fogh Rasmussen]] described the controversy as [[Denmark]]'s worst [[international crisis]] since [[World War II]].<ref>{{cite news|date=[[2006-02-15]]|title=
70,000 gather for violent Pakistan cartoons protest|publisher=Times Online|url=http://www.timesonline.co.uk/article/0,,25689-2041723,00.html}}</ref>


== Descriptions of the drawings ==
{{main|Descriptions of the Jyllands-Posten Muhammad cartoons}}


where int is the type name (the class) and a is the variable name (the object).
Some of the cartoons can be difficult to fully understand for those without knowledge of certain Danish language metaphors or awareness of individuals of note to the Danish public. Furthermore, certain cartoons have captions written in Danish and one in Persian. Detailed descriptions of the cartoons and translations of the captions as well as explanations concerning Danish cultural references are provided here.


After the previous declarations of CRectangle and rect, we can refer within the body of the program to any of the public members of the object rect as if they were normal functions or normal variables, just by putting the object's name followed by a dot (.) and then the name of the member. All very similar to what we did with plain data structures before. For example:
== Timeline ==
{{main|Timeline of the Jyllands-Posten Muhammad cartoons controversy}}


rect.set_values (3,4);
=== Debate about self-censorship ===
myarea = rect.area();
{{Muhammad cartoons}}
On [[September 17]] [[2005]], the Danish newspaper ''[[Politiken]]'' ran an article under the headline ''"Dyb angst for kritik af islam"'' <ref name="dybangst">{{cite news|date=[[2005-09-17]]|title=Dyb angst for kritik af islam|publisher=Politiken|url=http://politiken.dk/VisArtikel.sasp?PageID=397712}} {{da icon}}</ref> ("Profound fear of criticism of Islam"). The article discussed the difficulty encountered by the writer [[Kåre Bluitgen]], who was initially unable to find an [[illustrator]] who was prepared to work with Bluitgen on his children's book ''Koranen og profeten Muhammeds liv'' ([[English language|English]]: ''The [[Qur'an]] and the life of the Prophet Muhammad'' ISBN 87-638-0049-7). Three artists declined Bluitgen's proposal before one agreed to assist anonymously. According to Bluitgen:


<blockquote>One [artist declined], with reference to the murder in Amsterdam of the film director [[Theo van Gogh (film director)|Theo van Gogh]], while another [declined, citing the attack on] the lecturer at the [[Carsten Niebuhr|Carsten Niebuhr Institute]] in Copenhagen.<ref name="dybangst"/></blockquote>


The only members of rect that we cannot access from the body of our program outside the class are x and y, since they have private access and they can only be referred from within other members of that same class.
In October 2004, a lecturer at the Niebuhr institute at the [[University of Copenhagen]] had been assaulted by five assailants who opposed his reading of the [[Qur'an]] to non-Muslims during a lecture.<ref>{{cite news|date=[[2004-10-09]]|title=Overfaldet efter Koran-læsning|publisher=TV 2 (Denmark)|url=http://nyhederne.tv2.dk/article.php?id=1424089}} {{da icon}}</ref>


Here is the complete example of class CRectangle:
The refusal of the first three artists to participate was seen as evidence of [[self-censorship]] and led to much debate in Denmark, with other examples for similar reasons soon emerging. Comedian [[Frank Hvam]] declared that he would (hypothetically) dare to urinate on the Bible on television, but not on the Qur'an. <ref>{{cite news|title=Debat: Bangebuks versus Kulturminister, 3rd section, Bøger, p.7|publisher=Weekendavisen|date=[[2005-10-07]]|url=http://www.infomedia.dk}} {{da icon}}</ref><ref name="whyipub">{{cite news|date=[[2005-02-19]]|title=Why I Published Those Cartoons|publisher=WashingtonPost|url=http://www.washingtonpost.com/wp-dyn/content/article/2006/02/17/AR2006021702499.html}}</ref> The translators of an essay collection critical of Islam also wished to remain anonymous due to concerns about violent reprisals. {{Fact|date=February 2007}}


// classes example
=== Publication of the cartoons ===
#include <iostream>
{{wikinewshas|previous reports related to this article|
using namespace std;
* [[n:Eleven die in Libya over Muhammad cartoon T-shirt|Eleven die in Libya over Muhammad cartoon T-shirt]]
* [[n:Israeli group announces anti-semitic cartoons contest|Israeli group announces anti-semitic cartoons contest]]
* [[n:Protest held against Muhammad caricatures in Paris|Protest held against Muhammad caricatures in Paris]]
* [[n:French satirical weekly reprints caricatures|French satirical weekly reprints caricatures]]
* [[n:700,000 march in Beirut; Hezbollah leader lambasts Bush and Rice|700,000 march in Beirut; Hezbollah leader lambasts Bush and Rice]]
* [[n:Jyllands-Posten reconsiders printing holocaust denial cartoons|Jyllands-Posten reconsiders printing holocaust denial cartoons]]
* [[n:Hamshari newspaper plans cartoon response|Hamshari newspaper plans cartoon response]]
* [[n:Danish mission in Beirut set ablaze|Danish mission in Beirut set ablaze]]
* [[n:Danish and Austrian embassies in Tehran attacked|Danish and Austrian embassies in Tehran attacked]]
* [[n:New Zealand newspapers publish "Mohammad Cartoons"|New Zealand newspapers publish "Mohammad Cartoons"]]
* [[n:Danish and Norwegian embassies set on fire|Danish and Norwegian embassies set on fire]]
* [[n:Manipulation alleged in the "Mohammad Cartoons" affair|Manipulation alleged in the "Mohammad Cartoons" affair]]
* [[n:Darfur declares Swedish Foreign Minister unwelcome|Darfur declares Swedish Foreign Minister unwelcome]]
}}
On [[September 30]] [[2005]], the [[Newspaper|daily newspaper]] ''Jyllands-Posten'' ("The [[Jutland]] Post") published an article entitled "Muhammeds ansigt"<ref name="muhammeds_ansigt">{{cite news|first=Flemming|last=Rose|date=[[2005-09-30]]|title=Muhammeds ansigt|publisher=Jyllands-Posten|url=http://www.jp.dk/login?url=indland/artikel:aid=3293102:fid=11146}} {{da icon}}</ref> ("The face of Muhammad"). The article consisted of twelve cartoons (of which only some depicted Muhammad) and an explanatory text, in which [[Flemming Rose]], ''Jyllands-Posten''&#039;s culture editor, commented:


class CRectangle {
{{quotation|The modern, [[secularism|secular]] society is rejected by some Muslims. They demand a special position, insisting on special consideration of their own religious feelings. It is incompatible with contemporary democracy and freedom of speech, where you must be ready to put up with insults, mockery and ridicule. It is certainly not always attractive and nice to look at, and it does not mean that religious feelings should be made fun of at any price, but that is of minor importance in the present context. [...] we are on our way to a slippery slope where no-one can tell how the self-censorship will end. That is why Morgenavisen Jyllands-Posten has invited members of the Danish editorial cartoonists union to draw Muhammad as they see him. [...]|<ref name="muhammeds_ansigt" />}}
int x, y;
public:
void set_values (int,int);
int area () {return (x*y);}
};


void CRectangle::set_values (int a, int b) {
After the invitation from ''Jyllands-Posten'' to around forty different artists to give their interpretation of Muhammad, twelve [[caricaturist]]s chose to respond with a drawing each. Many also commented on the surrounding self-censorship debate. Three of these twelve cartoons were illustrated by Jyllands-Posten's own staff, including the "bomb" and "niqabs" cartoons.
x = a;
y = b;
}


int main () {
On [[February 19]], Rose explained his intent further In the ''Washington Post'':
CRectangle rect;
rect.set_values (3,4);
cout << "area: " << rect.area();
return 0;
}
area: 12


{{quotation|The cartoonists treated Islam the same way they treat Christianity, Buddhism, Hinduism and other religions. And by treating Muslims in Denmark as equals they made a point: We are integrating you into the Danish tradition of satire because you are part of our society, not strangers. The cartoons are including, rather than excluding, Muslims.|<ref name="whyipub" />}}


The most important new thing in this code is the operator of scope (::, two colons) included in the definition of set_values(). It is used to define a member of a class from outside the class declaration itself.
In October 2005, the Danish daily ''[[Politiken]]'' polled thirty-one of the forty-three members of the Danish cartoonist association. Twenty-three said they would be willing to draw Muhammad. One had doubts, one would not be willing because of fear of possible reprisals and six cartoonists would not be willing because they respected the Muslim ban on depicting the prophet.<ref>"Profetens ansigt: Ingen selvcensur blandt tegnere". Politiken 20. oktober 2005, 2. sektion, side 3</ref>


You may notice that the definition of the member function area() has been included directly within the definition of the CRectangle class given its extreme simplicity, whereas set_values() has only its prototype declared within the class, but its definition is outside it. In this outside declaration, we must use the operator of scope (::) to specify that we are defining a function that is a member of the class CRectangle and not a regular global function.
===Danish Prime Minister's meeting refusal ===


The scope operator (::) specifies the class to which the member being declared belongs, granting exactly the same scope properties as if this function definition was directly included within the class definition. For example, in the function set_values() of the previous code, we have been able to use the variables x and y, which are private members of class CRectangle, which means they are only accessible from other members of their class.
{{Muslims and controversies}}


The only difference between defining a class member function completely within its class and to include only the prototype and later its definition, is that in the first case the function will automatically be considered an inline member function by the compiler, while in the second it will be a normal (not-inline) class member function, which in fact supposes no difference in behavior.
Having received petitions from Danish imams, eleven ambassadors from Muslim-majority countries asked for a meeting with Danish Prime Minister [[Anders Fogh Rasmussen]] in [[12 October]] [[2005]], in order to discuss what they perceived as an "on-going smearing campaign in Danish public circles and media against Islam and Muslims". In a letter, the ambassadors mentioned not only the issue of the Muhammad cartoons, but also a recent indictment against [[Radio Holger]],<ref>{{cite news|title=Denmark targets extremist media |date=[[2005-08-17]]|url=
http://news.bbc.co.uk/2/hi/europe/4159220.stm|publisher=[[BBC News]]}}</ref> and statements by MP [[Louise Frevert]]<ref>{{da icon}} {{cite news|title=Ordene på Louise Freverts hjemmeside|date=[[2005-09-30]]|url=http://nyhederne.tv2.dk/baggrund/article.php?id=2946997
|publisher=TV2 (Denmark)}}</ref> and the [[Minister of culture|Minister of Culture]], [[Brian Mikkelsen]].<ref>{{da icon}} {{cite news|title=Mikkelsen blæser til ny kulturkamp|date=[[2005-09-25]]|url=http://nyhederne.tv2.dk/article.php?id=2923885|publisher=TV2 (Denmark)}}</ref> It concluded:


Members x and y have private access (remember that if nothing else is said, all members of a class defined with keyword class have private access). By declaring them private we deny access to them from anywhere outside the class. This makes sense, since we have already defined a member function to set values for those members within the object: the member function set_values(). Therefore, the rest of the program does not need to have direct access to them. Perhaps in a so simple example as this, it is difficult to see an utility in protecting those two variables, but in greater projects it may be very important that values cannot be modified in an unexpected way (unexpected from the point of view of the object).
{{quotation|We deplore these statements and publications and urge Your Excellency’s government to take all those responsible to task under law of the land in the interest of inter-faith harmony, better integration and Denmark's overall relations with the Muslim world.|<ref>{{PDFlink|[http://www.filtrat.dk/grafik/Letterfromambassadors.pdf Official letter from the 12 ambassadors]|74.5&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 76389 bytes -->}}</ref>}}


One of the greater advantages of a class is that, as any other type, we can declare several objects of it. For example, following with the previous example of class CRectangle, we could have declared the object rectb in addition to the object rect:
The government answered the ambassadors' request for a meeting with Rasmussen with a letter only: "The freedom of expression has a wide scope and the [[Politics of Denmark|Danish government]] has no means of influencing the press. However, Danish legislation prohibits acts or expressions of blasphemous or discriminatory nature. The offended party may bring such acts or expressions to court, and it is for the courts to decide in individual cases."<ref>{{PDFlink|[http://gfx-master.tv2.dk/images/Nyhederne/Pdf/side3.pdf Official response to ambassadors from A.F.Rasmussen]|545&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 558231 bytes -->}} </ref>


// example: one class, two objects
The ambassadors maintained that they had never asked for ''Jyllands-Posten'' to be prosecuted; possibly, the non-technical phrase of the letter, "to take NN to task under law", meant something like "to hold NN responsible within the limits of the law".<ref>{{cite news|title=Ambassadør-breve blev forvekslet i Politiken|date=[[2006-02-20]]|url=http://politiken.dk/VisArtikel.iasp?PageID=439519| publisher=Politiken}}</ref> Rasmussen replied: "Even a non-judicial intervention against ''Jyllands-Posten'' would be impossible within our system".<ref>{{da icon}} {{cite news|title=»Oversættelsen er helt uvæsentlig«|date=[[2006-02-21]]|url=http://politiken.dk/VisArtikel.iasp?PageID=439706| publisher=Politiken}}</ref>
#include <iostream>
using namespace std;


class CRectangle {
The Egyptian [[Foreign minister|Minister of Foreign Affairs]], Aboul Gheit, wrote several letters to the Prime Minister of Denmark and to the [[United Nations Secretary-General]] explaining that they did not want the Prime Minister to prosecute ''Jyllands-Posten''; they only wanted "an official Danish statement underlining the need for and the obligation of respecting all religions and desisting from offending their devotees to prevent an escalation which would have serious and far-reaching consequences".<ref>{{da icon}} {{cite news|title=Egypten gav Fogh mulighed for forsoning|date=[[2006-02-22]]|url=http://politiken.dk/VisArtikel.iasp?PageID=439859| publisher=Politiken}}</ref> Subsequently, the Egyptian government played a leading role in defusing the issue in the Middle East.<ref>{{da icon}} {{cite news|title=Egypten stod bag profetkampagne|date=[[2006-02-17]]|url=http://politiken.dk/VisArtikel.iasp?PageID=439149
int x, y;
| publisher=Politiken}}</ref>
public:
void set_values (int,int);
int area () {return (x*y);}
};


void CRectangle::set_values (int a, int b) {
The refusal to meet the ambassadors has been criticized by the Danish [[political opposition]], twenty-two Danish ex-ambassadors, and former Minister of Foreign Affairs, [[Uffe Ellemann-Jensen]].<ref>{{da icon}} {{cite news|title=Danish ambassadors criticise Andersen Fogh Rasmussen|date=[[2005-12-20]]|url=http://politiken.dk/VisArtikel.sasp?PageID=425730| publisher=Politiken}}</ref>
x = a;
y = b;
}


int main () {
===Judicial investigation of ''Jyllands-Posten''===
CRectangle rect, rectb;
On [[October 27]], [[2005]], a number of Muslim organizations filed a complaint with the Danish police claiming that ''Jyllands-Posten'' had committed an offence under section 140 and 266b of the [[Danish Criminal Code]].<ref name="danish_response_to_un_jan">{{cite news|title=Official Response by the Danish Government to the UN Special Rapporteurs|publisher=Ministry of Foreign Affairs of Denmark|date=[[2006-01-24]]|url=http://www.um.dk/NR/rdonlyres/00D9E6F7-32DC-4C5A-8E24-F0C96E813C06/0/060123final.pdf |format=PDF}} {{da icon}}</ref>
rect.set_values (3,4);
* Section 140<ref name="par140">{{cite news|title=§140 of the Danish criminal code|publisher=Juraportalen Themis|url=http://www.themis.dk/synopsis/docs/Lovsamling/Straffeloven_kap_15.html}} {{da icon}}</ref> of the [[Criminal Code]], known as the blasphemy law, prohibits disturbing [[public order]] by publicly ridiculing or insulting the dogmas of worship of any lawfully existing religious community in Denmark. Only one case has ever resulted in a sentence, a 1938 case involving an [[Anti-Semitism|anti-Semitic]] group. The most recent case was in 1971 when a [[program director]] of [[Danmarks Radio]] was charged, but found not guilty.<ref>{{cite news|url=http://www.dr.dk/Nyheder/Politik/2006/02/16/130153.htm|title=Den glemte paragraf|publisher=dr.dk|date=[[2006-02-16]]}} {{da icon}}</ref>
rectb.set_values (5,6);
* Section 266b<ref name="par266b">{{cite news|title=§266b of the Danish criminal code|publisher=Juraportalen Themis|url=http://www.themis.dk/synopsis/docs/Lovsamling/Straffeloven_kap_27.html}} {{da icon}}</ref> criminalises insult, threat or degradation of [[natural person]]s, by publicly and with [[malice (legal term)|malice]] attacking their race, [[Color (law)|color of]] skin, national or ethnical roots, faith or sexual orientation.
cout << "rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
return 0;
}
rect area: 12
rectb area: 30


On [[6 January]] [[2006]], the Regional [[Prosecutor|Public Prosecutor]] in [[Viborg, Denmark|Viborg]] discontinued the investigation as he found no basis for concluding that the cartoons constituted a [[Crime|criminal offence]]. His reason is based on his finding that the article concerns a subject of [[public interest]] and, further, on Danish [[case law]] which extends editorial freedom to journalists when it comes to a subject of public interest. He stated that, in assessing what constitutes an offence, the right to freedom of speech must be taken into consideration. He stated that the right to freedom of speech must be exercised with the necessary respect for other [[human rights]], including the right to protection against discrimination, insult and degradation, but no apparent violation of the law had occurred.<ref name="danish_response_to_un_jan"/> In a new hearing, the Director of Public Prosecutors in Denmark agreed.<ref name="rigsadvokaten PR"> {{cite news|title=Decision on possible criminal proceedings|publisher=Rigsadvokaten|date=[[2006-03-15]]|url=http://www.rigsadvokaten.dk/ref.aspx?id=890 |format=PDF}}</ref>


In this concrete case, the class (type of the objects) to which we are talking about is CRectangle, of which there are two instances or objects: rect and rectb. Each one of them has its own member variables and member functions.
=== Danish Imams tour the Middle East ===
{{main|Akkari-Laban dossier}}


Notice that the call to rect.area() does not give the same result as the call to rectb.area(). This is because each object of class CRectangle has its own variables x and y, as they, in some way, have also their own function members set_value() and area() that each uses its object's own variables to operate.
Two [[imam]]s who had been granted sanctuary in Denmark, dissatisfied with the reaction of the Danish Government and ''Jyllands-Posten'', created a forty-three-page document entitled "''Dossier about championing the prophet Muhammad peace be upon him''."<ref>{{cite news|title=The imam and the unbelievers of Denmark|publisher=Ekstra Bladet|date=[[2006-01-15]]|url=http://ekstrabladet.dk/VisArtikel.iasp?PageID=334426}}</ref> This consisted of several letters from Muslim organisations explaining their case including allegations of the mistreatment of Danish Muslims, citing the ''Jyllands-Posten'' cartoons (including the false claim that said publication was a government-run newspaper) and also supplementing the following causes of "pain and torment" for the authors:
# Pictures from another Danish newspaper, ''[[Weekendavisen]]'', which they called "even more offending" (than the original twelve cartoons);
# Hate-mail pictures and letters that the dossier's authors alleged were sent to Muslims in Denmark, said to be indicative of the rejection of Muslims by the Danish;
# A televised interview discussing Islam with [[Netherlands|Dutch]] [[Member of Parliament|member of parliament]] and Islam critic [[Ayaan Hirsi Ali|Hirsi Ali]], who had received the Freedom Prize "for her work to further freedom of speech and the rights of women" from the [[Danish Liberal Party]] represented by Anders Fogh Rasmussen.


That is the basic concept of object-oriented programming: Data and functions are both members of the object. We no longer use sets of global variables that we pass from one function to another as parameters, but instead we handle objects that have their own data and functions embedded as members. Notice that we have not had to give any parameters in any of the calls to rect.area or rectb.area. Those member functions directly used the data members of their respective objects rect and rectb.
Appended to the dossier were multiple clippings from ''Jyllands-Posten'', multiple clippings from ''Weekendavisen'', some clippings from Arabic-language papers and three additional images which also had no connection with Denmark. [[Image:Pig_person.jpg|200px|thumb|right|French pig-squealing contestant from the imams' dossier. Original caption included in the dossier: ''"Here is the real image of Muhammad."'']]


The imams claimed that the three additional images were sent anonymously by mail to Muslims who were participating in an online debate on ''Jyllands-Posten'',<ref>{{cite news|title=Sådan gik chatten - Bjerager og Akkari|publisher=TV2|date=[[2006-03-08]]|url=http://politik.tv2.dk/article.php/3617652.html}} See question asked by ''xaria'' and answered by Akkari {{da icon}}</ref> and were apparently included to illustrate the perceived atmosphere of Islamophobia in which they lived, and to trigger anti-Western hatred.<ref>{{cite news|title=What the Muhammad cartoons portray|publisher=BBC|date=[[2006-02-09]]|url=http://news.bbc.co.uk/2/hi/middle_east/4693292.stm}}</ref> On [[February 1]] [[BBC World]] incorrectly reported that one of them had been published in ''Jyllands-Posten''.<ref>{{cite news|title=Imam viste falske billeder|publisher=Jyllands-Posten|date=[[2006-01-30]]|url=http://www.jp.dk/indland/artikel:aid=3527718}} {{da icon}}</ref> This image was later found to be a wire-service photo of a contestant at a French pig-squealing contest.<ref>[http://www.neandernews.com/?p=54 Neandernews: Danish Imams Busted!][http://news.bbc.co.uk/2/hi/south_asia/4686536.stm A clash of rights and responsibilities, BBC]</ref><ref>[http://www.msnbc.msn.com/id/8959820 Duo hogs top prize in pig-squealing contest]</ref> One of the other two additional images (a photo) portrayed a Muslim being mounted by a dog while praying, and the other (a cartoon) portrayed Muhammad as a demonic paedophile. Equipped with the dossier, the two imams circulated it throughout the Muslim world, presenting their case to many influential religious and [[Politician|political leaders]], asking for support.<ref>[http://service.spiegel.de/cache/international/0,1518,398624,00.html Alienated Danish Muslims Sought Help from Arabs]</ref>


Constructors and destructors
The dossier contained such statements as the following:
Objects generally need to initialize variables or assign dynamic memory during their process of creation to become operative and to avoid returning unexpected values during their execution. For example, what would happen if in the previous example we called the member function area() before having called function set_values()? Probably we would have gotten an undetermined result since the members x and y would have never been assigned a value.
* We urge you [recipient of the letter or dossier] to &mdash; on the behalf of thousands of believing Muslims &mdash; to give us the opportunity of having a constructive contact with the press and particularly with the relevant decision makers, not briefly, but with a scientific methodology and a planned and long-term programme seeking to make views approach each other and remove misunderstandings between the two parties involved. Since we do not wish for Muslims to be accused of being backward and narrow, likewise we do not wish for Danes to be accused of ideological arrogance either. When this relationship is back on its track, the result will bring satisfaction, an underpinning of security and the stable relations, and a flourishing Denmark for all that live here.
In order to avoid that, a class can include a special function called constructor, which is automatically called whenever a new object of this class is created. This constructor function must have the same name as the class, and cannot have any return type; not even void.
* The faithful in their religion (Muslims) suffer under a number of circumstances, first and foremost the lack of official recognition of the Islamic faith. This has led to a lot of problems, especially the lack of right to build mosques [...]
* Even though they [the Danes] belong to the [[Christianity|Christian faith]], the secularizations have overcome them, and if you say that they are all infidels, then you are not wrong.
* We [Muslims] do not need lessons in democracy, but it is actually us, who through our deeds and speeches educate the whole world in democracy.
* This [Europe's] dictatorial way of using democracy is completely unacceptable.


We are going to implement CRectangle including a constructor:
The inclusion in the dossier of the cartoons from ''Weekendavisen'' was possibly a misunderstanding, as these were more likely intended as parodies of the pompousness of ''Jyllands-Posten'''s cartoons than as comments on the prophet in their own right.<ref>[http://www.dr.dk/Nyheder/Indland/2006/01/04/161736.htm Trossamfund angriber Muhammed-satire i Weekendavisen] {{da icon}}</ref> They consist of reproductions of works such as the ''[[Mona Lisa]]'' (caption: ''For centuries, a previously unknown society has known that this is a painting of the Prophet, and guarded this secret. The back page's anonymous artist is doing everything he can to reveal this secret in his contribution. He has since then been forced to go underground, fearing for the wrath of a crazy albino imam''). This is an obvious parody of the [[Da Vinci Code]].


// example: class constructor
At a [[6 December]] [[2005]] summit of the [[Organisation of the Islamic Conference]], with many [[Head of State|heads of state]] in attendance, the dossier was handed around on the sidelines first,<ref>{{cite news|title= How a meeting of leaders in Mecca set off the cartoon wars around the world|publisher=The Independent|date=[[2006-02-10]]|url=http://news.independent.co.uk/world/middle_east/article344482.ece}}</ref> and eventually an official communiqué was issued, demanding that the [[United Nations]] impose [[international sanctions]] upon Denmark.<ref name="UN resolution">{{cite news|date=[[2006-01-29]]|title=Muslims seek UN resolution over Danish prophet cartoons|publisher=IslamOnLine|url=http://www.islam-online.net/English/News/2006-01/30/article01.shtml}}</ref>
#include <iostream>
using namespace std;


class CRectangle {
=== ''Jyllands-Posten'' response ===
int width, height;
In response to protests from Muslim groups, ''Jyllands-Posten'' published two open letters on its website, each of them in a [[Danish language|Danish]] and an [[Arabic language|Arabic]] version.<ref>{{PDFlink|[http://www1.jp.dk/indland/doku/jp_aabent_brev.pdf Jyllands-Posten's letter in Arabic]|18.2&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 18709 bytes -->}} {{ar icon}}</ref> The second letter, dated [[30 January]] [[2006]], also has an [[English language|English]] version:<ref>{{cite news|date=[[2006-01-30]]|title=Honourable Fellow Citizens of the Muslim World|url= http://www.jp.dk/meninger/ncartikel:aid=3527646|publisher=Jyllands-Posten}}</ref>
public:
CRectangle (int,int);
int area () {return (width*height);}
};


CRectangle::CRectangle (int a, int b) {
{{quotation|In our opinion, the 12 drawings were sober. They were not intended to be offensive, nor were they at variance with Danish law, but they have indisputably offended many Muslims for which we apologize.}}
width = a;
height = b;
}


int main () {
On [[February 26]], the cartoonist who had drawn the ''bomb in turban'' picture, the most
CRectangle rect (3,4);
controversial of the twelve, explained:
CRectangle rectb (5,6);
cout << "rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
return 0;
}
rect area: 12
rectb area: 30


{{quotation|There are interpretations of it [the drawing] that are incorrect. The general impression among Muslims is that it is about Islam as a whole. It is not. It is about certain fundamentalist aspects, that of course are not shared by everyone. But the fuel for the terrorists’ acts stem from interpretations of Islam. [...] if parts of a religion develop in a totalitarian and aggressive direction, then I think you have to protest. We did so under the other 'isms.|<ref>{{cite news|date=[[2006-02-26]]|title=Jyllands-Posten: Bomben's Ophavsmand|url= http://www.jp.dk/udland/artikel:aid=3579334:fid=11338/|publisher=Jyllands-Posten}} {{da icon}}</ref>}}


As you can see, the result of this example is identical to the previous one. But now we have removed the member function set_values(), and have included instead a constructor that performs a similar action: it initializes the values of x and y with the parameters that are passed to it.
===Reprinting in other newspapers===


Notice how these arguments are passed to the constructor at the moment at which the objects of this class are created:
[[Image:Page-1-of-El-Fagr.org-egyptian-newspaper-Oct-17-2005.jpg|125px|thumb|right|''[[El Fagr]]'s [[October 17]], [[2005]]'' headline page.]]
{{see|List of newspapers that reprinted Jyllands-Posten's Muhammad cartoons}}
In 2005, the Muhammad cartoons controversy received only minor media attention outside of Denmark. Six of the cartoons were first reprinted by the Egyptian newspaper ''[[El Fagr]]'' on [[October 17]], [[2005]],<ref>{{cite news|date=[[2005-02-10]]|title=Danes Blame Imams for Satire Escalation, Survey Says (Update1)|publisher=Bloomberg|url= http://www.bloomberg.com/apps/news?pid=10000085&sid=a8hEmi2ja5cg&refer=europe}}</ref><ref>{{cite news|date=[[2006-02-08]]|title=No Danish Treatment for an Egyptian Newspaper|publisher=FreedomForEgyptians|url= http://freedomforegyptians.blogspot.com/2006/02/egyptian-newspaper-pictures-that.html}}</ref> along with an article strongly denouncing them, but publication did not provoke any condemnations or other reactions from religious or government authorities. Between October 2005 and the end of January 2006, examples of the cartoons were reprinted in major [[Europe]]an newspapers from the [[Netherlands]], [[Germany]], [[Scandinavia]], [[Belgium]] and [[France]]. Very soon after, as protests grew, there were further re-publications around the globe, but primarily in [[continental Europe]].


CRectangle rect (3,4);
Notable for a lack of republication of the cartoons were most major newspapers in the [[USA]]<ref>{{cite news|date=[[2006-02-04]]|title=A media dilemma: The rest of a story|publisher=Philadelphia Inquirer|url=http://www.philly.com/mld/inquirer/news/front/13788640.htm}}</ref> and the [[United Kingdom]],<ref>{{cite news|date=[[2006-02-06]]|title=US, British media tread carefully in cartoon furor|publisher=Christian Science Monitor|url=http://www.csmonitor.com/2006/0206/dailyUpdate.html}}</ref> where editorials covered the story without including them. Several [[List of newspapers that reprinted Jyllands-Posten's Muhammad cartoons#Newspapers closed.2C editors fired or arrested|newspapers were closed and editors fired or arrested]] for their decision or intention to re-publish the cartoons, including the shutting down of a 60 year old [[Sarawak Tribune|Malaysian newspaper]] permanently.
CRectangle rectb (5,6);


=== Economic and human costs ===
{{main|Economic and human costs of the Jyllands-Posten Muhammad cartoons controversy}}
[[Image:Cartoonmap-key.png|thumb|left|Map shows a colored matrix of republication (blue) and violence (red)]]
<!--
What started with the problem of a Danish author trying to find an illustrator for his book became an international controversy, as a result of which many governments and international organizations have issued statements. The primary economic and human costs stemmed from rioting that left more than 130 people dead and caused massive property damage. Boycotts and other economic measures led to job losses and missed business opportunities on the scale of millions of [[Euro]]s.
-->
A consumer [[boycott]] was organised in [[Saudi Arabia]], [[Kuwait]], and other Middle East countries.<ref>{{cite news|date=[[2006-02-10]]|title=The Inciters and the Incited|publisher=Der Spiegel International Edition|url=http://service.spiegel.de/cache/international/spiegel/0,1518,400519,00.html}}</ref>
For weeks, numerous notable demonstrations and other protests against the cartoons took place worldwide. Rumours spread via [[Short message service|SMS]] and [[Word of mouth|word-of-mouth]].<ref>{{cite news|date=[[2006-02-09]]|title=E-Mail, Blogs, Text Messages Propel Anger Over Images|publisher=Washington Post|url=http://www.washingtonpost.com/wp-dyn/content/article/2006/02/08/AR2006020802293.html}}</ref>On [[February 4]] [[2006]], the Danish and [[Norway|Norwegian]] embassies in [[Syria]] were set ablaze, though with no injuries. In [[Beirut]], the Danish [[Diplomatic mission|Embassy]] was set on fire,<ref>{{cite news|date=[[2006-02-05]]|title=Protesters burn consulate over cartoons|publisher=CNN|url=http://www.cnn.com/2006/WORLD/asiapcf/02/05/cartoon.protests/index.html}}</ref> leaving one protester dead.<ref>{{cite news|date=[[2006-02-06]]|title=Protestors killed as global furor over cartoons escalates|publisher=Middle East Times|url=http://www.metimes.com/articles/normal.php?StoryID=20060206-081448-7380r}}</ref> Altogether, at least 139 people were killed in protests,<ref>{{cite news|date=[[2006-03-02]]| title=Cartoon Body Count|publisher=Web|url=http://web.archive.org/web/20060326071135/http://www.cartoonbodycount.com/}}</ref> mainly in Nigeria, Libya, Pakistan and Afghanistan.


Constructors cannot be called explicitly as if they were regular member functions. They are only executed when a new object of that class is created.
Several [[death threat]]s and reward offers for killing those responsible for the cartoons have been made,<ref>{{cite web|title=Another Bounty on 12 Cartoonists’ Heads|publisher=Agora|url=
http://agora.blogsome.com/2006/03/12/another-bounty-on-12-cartoonists-heads|date=[[2006-03-12]]}} </ref> resulting in the cartoonists going into hiding.<ref>[http://www.timesonline.co.uk/article/0,,3-2024306,00.html TimesOnline: Danish cartoonists fear for their lives]</ref>. Four ministers have resigned amidst the controversy, among them [[Roberto Calderoli]] and [[Laila Freivalds]].<ref>{{cite news|date=[[2006-03-21]]|title=Libya suspends minister over riot|publisher=BBC News|url=http://news.bbc.co.uk/1/hi/world/africa/4727810.stm}}</ref> In [[India]], Haji Yaqoob Qureishi, a minister in [[Uttar Pradesh]] state government announced in [[February 2006]] a cash reward of Rs 51 crore (roughly about US$11 million) for anyone who beheads 'the Danish cartoonist' who caricatured Prophet Mohammad.<ref>http://209.157.64.201/focus/f-news/1580915/posts</ref> <ref>http://www.tribuneindia.com/2006/20060326/nation.htm</ref><ref>http://timesofindia.indiatimes.com/articleshow/1419344.cms</ref> [[Condoleezza Rice]], [[United States Secretary of State|Secretary of State of the United States]] of America has accused Iran and Syria of [[government-organized demonstration|organizing many of the recent protests]] in Iran, Syria and Lebanon.<ref>http://www.cbsnews.com/stories/2006/02/08/world/main1298998.shtml</ref><ref>http://www.cbsnews.com/stories/2006/02/08/world/main1298998.shtml Rice: Iran, Syria Behind Cartoon Riots by CBS News</ref>


You can also see how neither the constructor prototype declaration (within the class) nor the latter constructor definition include a return value; not even void.
The Western media dubbed the series of demonstrations organized in February 2006 by certain Middle Eastern governments and radical clerics as the "Cartoon Intifada".<ref>http://www.townhall.com/opinion/columns/cliffordmay/2006/02/09/185968.html The Cartoon Intifada by Clifford D. May</ref>


The destructor fulfills the opposite functionality. It is automatically called when an object is destroyed, either because its scope of existence has finished (for example, if it was defined as a local object within a function and the function ends) or because it is an object dynamically assigned and it is released using the operator delete.
On [[September 9]], [[2006]], it was announced that the Muslim boycott of Danish goods had reduced exports to the Muslim world by 15.5%, costing about €134 million.<ref>{{cite web|url=http://news.bbc.co.uk/2/hi/europe/5329642.stm|title=Cartoons row hits Danish exports|publisher=[[BBC News]]|date=2006-09-09|accessdate=2006-09-09}}</ref> However, the ''Guardian'' newspaper in the UK also reported, "While Danish milk products were dumped in the Middle East, fervent rightwing Americans started buying [[Bang & Olufsen]] stereos and Lego. In the first quarter of this year Denmark’s exports to the US soared 17%."<ref>http://www.guardian.co.uk/international/story/0,,1884323,00.html</ref>
{{-}}


The destructor must have the same name as the class, but preceded with a tilde sign (~) and it must also return no value.
===Further police investigations===
* The French/Algerian journalist [[Mohammed Sifaoui]] <ref>[http://www.telegraph.co.uk/arts/main.jhtml?xml=/arts/2003/08/31/bosif24.xml Inside al Qaeda by Mohamed Sifaoui]</ref> secretly filmed<ref>{{cite news|date=[[2006-03-23]]|title=Video footage of the French TV documentary|publisher=TV2|url=http://www.savefile.com/files.php?fid=6735165}}</ref><ref>{{cite news|date=[[2006-03-25]]|title=Video footage of Abu Laban|publisher=Denmark radio|url=http://www.dr.dk/Forms/Published/PlaylistGen.aspx?qid=176564}}</ref> [[Ahmed Akkari]], spokesman for the group of Danish Imams that toured the Middle East, in conversation with Sheikh Raed Hlayhel (head of the 2nd delegation), speculating that if MP [[Naser Khader]] ever became a minister, that two men would show up and have him and his ministry bombed.<ref>{{cite news|language=da|date=[[2006-03-23]]|title=Tvivl om oversættelse af Akkari|publisher=Denmark radio|url=http://www.dr.dk/Nyheder/Indland/2006/03/23/105907.htm}}</ref> [[Ahmad Abu Laban]] was also filmed talking about a man who wants "to wreak absolute havoc" and "wants to join the fray and turn it into a [[Suicide attack|Martyr operation]] right now."<ref>{{cite news|date=[[2006-03-25]]|title=Danish Imam Reveals `Martyr Action' Plot, Danmarks Radio Says|publisher=Bloomberg|url=http://www.bloomberg.com/apps/news?pid=10000085&sid=aV6jPyhgfzL0&refer=europe}}</ref> Akkari initially denied the remarks, then explained he was only [[joke|joking]].<ref>{{cite news|date=[[2006-03-23]]|title=Danish police to probe imam's bomb threats|publisher=Reuters|url=http://today.reuters.co.uk/news/newsArticle.aspx?type=worldNews&storyID=2006-03-23T164714Z_01_L2397527_RTRUKOC_0_UK-RELIGION-DENMARK-THREATS.xml&archived=False}}</ref> Both men were investigated, but no charges were brought.


The use of destructors is especially suitable when an object assigns dynamic memory during its lifetime and at the moment of being destroyed we want to release the memory that the object was allocated.
* Police in [[Berlin]] overwhelmed [[Amir Abdur Rehman Cheema|Amer Cheema]], a student from Pakistan, as he entered the office building of [[Die Welt]] newspaper, armed with a large knife. Cheema admitted to trying to kill editor Roger Köppel for reprinting the Mohammad cartoons in the newspaper. On [[May 3]] [[2006]], Cheema [[Suicide|committed suicide]] in his [[prison cell]]. Cheema's family and Pakistani media claim he was tortured to death.<ref>{{cite news|url=http://www.spiegel.de/politik/deutschland/0,1518,414669,00.html|title=Selbstmord nach versuchtem Angriff auf Chefredakteur der "Welt"|publisher=[[Der Spiegel]]|date=May 5, 2006}}.</ref> 30,000 people attended Cheema's funeral near [[Lahore]]<ref>{{cite news|url=http://in.news.yahoo.com/060513/137/6480q.html|title=Up to 30,000 mourn Pakistani who died in German jail|publisher=Reuters/Yahoo|date=May 13, 2006}}.</ref>.


// example on constructors and destructors
*Two [[suitcase bombs]] were discovered in trains near the German towns of [[Dortmund]] and [[Koblenz]], undetonated due to an assembly error. Video footage from [[Cologne]] [[train station]], where the bombs were put on the trains, led to the arrest of two Lebanese students in Germany, Youssef el-Hajdib and Jihad Hamad, and subsequently of three suspected co-conspirators in Lebanon<ref>{{cite news|title=Lebanon arrests fourth suspect in German bomb case|org=BBC|url=http://today.reuters.com/News/CrisesArticle.aspx?storyId=L02136965}}</ref>. On [[1 September]] [[2006]], Jörg Ziercke, head of the [[Bundeskriminalamt]] (Federal Police), reports that the suspects saw the Muhammad cartoons as an "assault by the West on Islam" and the "initial spark" for the attack, originally planned to coincide with the [[2006 FIFA World Cup|2006 Football World Cup in Germany]].<ref>{{cite news|title= Suspects behind failed German train bombings motivated Prophet Muhammad cartoons: investigator|org=International Herald Tribune|url=http://www.iht.com/articles/ap/2006/09/02/europe/EU_GEN_Germany_Terrorism_Investigation.php}}</ref><ref>{{cite news|title=Bahn-Anschläge schon zur Fußball-WM geplant|org=Spiegel|url=http://www.spiegel.de/panorama/0,1518,434812,00.html}}</ref> One of the suspects, Youssef el-Hajdib, was arrested heading to Denmark. Police found the [[Telephone number|phone number]] of [[Abu Bashar]], the leader of the Danish Imams' first cartoon-related delegation to the Middle East, in Hadjib's pockets. Abu Bashar denies knowing al-Hajdib.<ref>{{cite news|title=9 arrested by Denmark in reported terror plot|org=International Heral Tribune|url=http://www.iht.com/articles/2006/09/05/news/denmark.php}}</ref>
#include <iostream>
using namespace std;


class CRectangle {
===Anniversary flare-up===
int *width, *height;
{{wikinews|New agitations over cartoons of Prophet Mohammed}}
public:
One year after the publication of the original cartoons, a video surfaced showing members of the [[Danish People's Party|Danish People's Party's]] youth wing engaged in a contest of drawing pictures that insult Muhammad. Publicity surrounding the contest led to renewed tension between the Islamic world and Denmark,<ref>{{cite news|title= Anti-Muslim video sparks new outrage against Denmark|org=The Independent|url=http://news.independent.co.uk/europe/article1826296.ece}}</ref> with the OIC and many countries weighing in. The Danish government condemned the youths, and those who were depicted in the video went into hiding after receiving death threats.
CRectangle (int,int);
~CRectangle ();
int area () {return (*width * *height);}
};


CRectangle::CRectangle (int a, int b) {
Two weeks into this episode, a Danish [[artist]]s' group, "[[Defending Denmark]]", claimed responsibility for the video and said it had [[infiltration|infiltrated]] the Danish People's Party Youth for 18 months claiming "to document (their) [[Far right|extreme right]] wing associations".<ref>{{cite news|title=Web sites remove videos mocking Muhammad|org=AP|url= http://news.yahoo.com/s/ap/20061010/ap_on_re_eu/denmark_prophet_drawings}}</ref>
width = new int;
height = new int;
*width = a;
*height = b;
}


CRectangle::~CRectangle () {
A few days later a new episode surfaced, when a member of the [[Radikal Ungdom|Social-liberal youth movement]] stated, that members of the movement had also drawn pictures of Muhammad during a weekend meeting. Unlike the Danish People's Party Youth's drawings, this episode was not condoned by the youth movement, but was done by individuals.
delete width;
delete height;
}


int main () {
All four videos of the controversy can be seen [http://religiousfreaks.com/2006/10/09/danish-peoples-party-youth-wing-salutes-muhammed/ here].
CRectangle rect (3,4), rectb (5,6);
cout << "rect area: " << rect.area() << endl;
cout << "rectb area: " << rectb.area() << endl;
return 0;
}
rect area: 12
rectb area: 30


== Opinions and issues ==
{{seealso|Opinions on the Jyllands-Posten Muhammad cartoons controversy}}
{{seealso|International reactions to the Jyllands-Posten Muhammad cartoons controversy}}
===Danish journalistic tradition===
[[Freedom of speech]] was obtained in a new Danish constitution<ref>{{PDFlink|[http://www.folketinget.dk/pdf/constitution.pdf The Danish constitution]|120&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 123774 bytes -->}} </ref> in 1849, and has been defended vigorously ever since. It was suspended for the duration of the German [[occupation of Denmark]] in [[World War II]]. Freedom of expression is also protected by the [[European Convention on Human Rights]] and the [[International Covenant on Civil and Political Rights]].


The [[List of newspapers in Denmark|Danish newspapers]] are privately owned and independent from the government, and Danish freedom of expression is quite far-reaching, even by Western standards. In the past, this has provoked official protests from Germany about printing [[Neo-Nazism|neo-nazi]] propaganda, and from Russia for "solidarity with terrorists."<ref>{{cite news|url=http://news.bbc.co.uk/2/hi/europe/2369083.stm| title=Chechen rebels seek talks with Moscow|publisher=BBC News|date=28 October, 2002}}</ref> The organization [[Reporters Without Borders]] ranks Denmark at the top of its Worldwide Press Freedom Index for 2005.<ref>{{cite web|url=http://www.rsf.org/rubrique.php3?id_rubrique=554|publisher=Reporters Without Borders|title=World Press Freedom Index, 2005}}</ref>


Overloading Constructors
Religion is often portrayed in ways that other societies consider illegal blasphemy.<ref>[http://www.interights.org/page.php?dir=Publication&page=wingrove.php Painting by Jens Jørgen Thorsen]</ref><ref>[http://www.imdb.com/title/tt0104551/ Danish movie Jesus vender tilbage] on Internet Movie Database</ref><ref>[http://movies2.nytimes.com/gst/movies/movie.html?v_id=211141 Jesus vender tilbage plot description in the New York Times]</ref> While ''[[Jyllands-Posten]]'' has published [[satire|satirical]] cartoons depicting Christian figures,<ref>[http://www.filtrat.dk/sandbox/images/uploads/Hvem20sagde20hvad.jpg Drawing from Jyllands-Posten]</ref> it did, in 2003, reject unsolicited [[Surreal humour|surreal]] cartoons depicting Jesus,<ref>[http://www.zieler.dk/images.asp?fnavn=1opstandelsesspalte%202004.jpg&mappe=m-images&home=m-index.asp Zieler, Resurrection]</ref> opening them to accusations of a [[double standard]].<ref>{{cite web|url=http://www.guardian.co.uk/international/story/0,,1703501,00.html|title=Danish paper rejected Jesus cartoons|publisher=The Guardian|date=February 6, 2006|author=Gwladys Fouché}}</ref> In February 2006, ''Jyllands-Posten'' also refused to publish [[Iran Holocaust Cartoons Contest|Holocaust denial cartoons]] offered by an Iranian newspaper.<ref>{{cite web|url=http://www.jp.dk/login?url=english_news/artikel:aid=3548990|title=
Like any other function, a constructor can also be overloaded with more than one function that have the same name but different types or number of parameters. Remember that for overloaded functions the compiler will call the one whose parameters match the arguments used in the function call. In the case of constructors, which are automatically called when an object is created, the one executed is the one that matches the arguments passed on the object declaration:
No Holocaust Cartoons in Morgenavisen Jyllands-Posten|publisher=''Jyllands-Posten''|date=2006-02-09|accessdate=2006-09-17}}</ref><ref>[http://news.scotsman.com/international.cfm?id=204162006 Danish paper refuses Holocaust cartoons, ''The Scotsman'', ''9 February 2006'']</ref> Six of the less controversial entries were later published by ''[[Dagbladet Information]]'', after the editors consulted the main rabbi in Copenhagen,<ref>{{cite web|url=http://news.bbc.co.uk/2/hi/europe/5327852.stm|title=Paper reprints Holocaust cartoons|publisher=[[BBC News]]|date=2006-09-08|accessdate=2006-09-08}}</ref> and three cartoons were in fact later reprinted in ''Jyllands-Posten''.<ref>{{cite web|url=http://www.jp.dk/login?url=kultur/artikel:aid=3961206|title=
// overloading class constructors
Holocaust-konkurrence flopper|publisher=''Jyllands-Posten''|date=2006-09-15|accessdate=2006-09-17}}</ref><ref>{{cite web|url=http://epaper.jp.dk/16-09-2006/demo/JP_01-16_17.html|title=
#include <iostream>
Holocaust-konkurrence flopper (p. 16)|publisher=''Jyllands-Posten''|date=2006-09-16|accessdate=2006-09-17}}</ref> After the competition had finished, ''Jyllands-Posten'' also reprinted the winning and [[runner-up]] cartoons.<ref>{{cite web|url=http://epaper.jp.dk/03-11-2006/demo/JP_01-20_21.html|title=
using namespace std;
Iran varsler endnu flere Holocaust-konkurrencer (p. 20)|publisher=''Jyllands-Posten''|date=2006-11-03|accessdate=2006-11-05}}</ref>


class CRectangle {
=== Muslim tradition ===
int width, height;
==== Aniconism ====
public:
{{main|Aniconism in Islam|Depictions of Muhammad}}
CRectangle ();
CRectangle (int,int);
int area (void) {return (width*height);}
};


CRectangle::CRectangle () {
[[Image:Aziz efendi-muhammad alayhi s-salam.jpg|160px|thumb|"Muhammad" in Arabic calligraphy.]]
width = 5;
Owing to the traditions of [[aniconism]] in Islam, the majority of [[art]] concerning Muhammad is [[Islamic calligraphy|calligraphic]] in nature. The [[Qur'an]] condemns [[idolatry]], and pictoral forms are seen as ostensibly close to idol worship. These are found in A[[hadith]] [plural of Hadith]: ''"[[Abd-Allah ibn Umar|Ibn ‘Umar]] reported Allah’s Messenger ([[Peace be upon him (Islam)|pbuh]]) having said: Those who paint pictures would be punished on the Day of [[Resurrection]] and it would be said to them: Breathe [[soul]] into what you have created."'' <ref>[http://www.usc.edu/dept/MSA/fundamentals/hadithsunnah/muslim/024.smt.html#024.5268 Translation of Sahih Muslim, Book 24]</ref><ref>[http://www.usc.edu/dept/MSA/fundamentals/hadithsunnah/muslim/024.smt.html#024.5250 Translation of Sahih Muslim, Book 24]</ref><ref>[http://www.usc.edu/dept/MSA/fundamentals/hadithsunnah/muslim/024.smt.html#024.5252 Translation of Sahih Muslim, Book 24]</ref><ref>[http://www.islamtoday.com/showme2.cfm?cat_id=2&sub_cat_id=811 Islam Today: Drawing Pictures & Producing Animated Cartoons]</ref>
height = 5;
[[Image:Mohammed_kaaba_1315.jpg|160px|thumb|left|Muhammad rededicating the [[Kaaba]] [[Black Stone]]. In Jami Al-Tawarikh "The [[Universal History]]" by [[Rashid al-Din|Rashid Al-Din]], at the [[University of Edinburgh]] library; [[Circa|c.]] 1315.]]
}
Within Muslim communities, views have varied regarding pictorial representations. [[Shi'a Islam]] has been generally tolerant of pictorial representations of human figures, including Muhammad.<ref>[http://www.sistani.org/html/eng/menu/4/?lang=eng&view=d&code=234&page=1 Answers of Grand Ayatollah Uzma Sistani]</ref> Contemporary [[Sunni Islam]] generally forbids any pictorial representation of Muhammad,<ref>[http://www.cair-net.org/default.asp?Page=articleView&id=38845&theType=NB CAIR press release]</ref> but has had periods allowing depictions of Muhammad's face covered with a veil or as a featureless void emanating light.
A few contemporary interpretations of Islam, such as some adherents of [[Wahhabism]] and [[Salafism]], are entirely [[Aniconism|aniconistic]] and condemn pictorial representations of any kind.
The [[Taliban]], while in power in [[Afghanistan]], banned television, photographs and images in newspapers and destroyed paintings including [[fresco]]es in the vicinity of the [[Buddhas of Bamyan]].<ref>[http://www.bbc.co.uk/history/recent/sept_11/afghan_culture_03.shtml Afghanistan: At the Crossroads of Ancient Civilisations]</ref>


CRectangle::CRectangle (int a, int b) {
==== Prohibition to insult Muhammad ====
width = a;
In Muslim societies, insulting the Islamic prophet Muhammad is considered one of the gravest of all crimes. Some interpretations of the [[Shariah]], in particular the relatively fringe [[Salafi]] group, state that any insult to Muhammad warrants death.<ref>{{cite news|title=Question #22809: Ruling on one who insults the Prophet |publisher=Islam Q & A |url=http://www.islam-qa.com/index.php?ln=eng&ds=qa&lv=browse&QR=22809&dgn=4}}</ref>
height = b;
}


int main () {
However, the [[Organization of the Islamic Conference]] has denounced calls for the death of the Danish cartoonist. OIC's Secretary General [[Ekmeleddin İhsanoğlu|Ekmeleddin Ihsanoglu]] stated in a press release:
CRectangle rect (3,4);
<blockquote>
CRectangle rectb;
''The Secretary General appeals to the Muslims to stay calm and peaceful in the wake of sacrilegious depiction of Prophet Muhammad ([[Peace be upon him (Islam)|PBUH]]) which has deeply hurt their feelings. He has stated that Islam being the religion of tolerance, mercy and peace teaches them to defend their faith through democratic and legal means.''<ref>{{cite web|url=http://www.oic-oci.org/press/english/2006/January%202006/denemark-3.htm|title=Statement by H.E Prof Ekmeleddin Ihsanoglu Secretary General of the OIC|date=[[January 28]], [[2006]]||author=[[Organization of the Islamic Conference|OIC]]}}</ref>
cout << "rect area: " << rect.area() << endl;
</blockquote>
cout << "rectb area: " << rectb.area() << endl;
return 0;
}
rect area: 12
rectb area: 25


=== Associating Islam with terrorism ===
Many Muslims have explained their anti-cartoon stance as against ''insulting'' pictures and not so much as against pictures in ''general''. According to the [[BBC]]:


In this case, rectb was declared without any arguments, so it has been initialized with the constructor that has no parameters, which initializes both width and height with a value of 5.
{{quotation|It is the satirical intent of the cartoonists and the association of the Prophet with terrorism, that is so offensive to the vast majority of Muslims.|<ref>{{cite news|first=Magdi|last=Abdelhadi|title=Cartoon row highlights deep divisions|date=[[4 February]] [[2006]]|publisher=[[BBC News]]|url=http://news.bbc.co.uk/2/hi/middle_east/4678220.stm}}</ref>}}


Important: Notice how if we declare a new object and we want to use its default constructor (the one without parameters), we do not include parentheses ():
{{quotation|Why is the insult so deeply felt by some Muslims? Of course, there is the prohibition on images of Muhammad. But one cartoon, showing the Prophet wearing a turban shaped as a bomb with a burning fuse, extends the caricature of Muslims as terrorists to Muhammad. In this image, Muslims see a depiction of Islam, its prophet and Muslims in general as terrorists. This will certainly play into a widespread perception among Muslims across the world that many in the West harbour a hostility towards &ndash; or fear of &ndash; Islam and Muslims.|<ref>{{cite news|title=Q&A: Depicting the Prophet Muhammad|date=[[2 February]] [[2006]]|publisher=[[BBC News]]|url=http://news.bbc.co.uk/2/hi/middle_east/4674864.stm}}</ref>}}


CRectangle rectb; // right
=== Islamism and accusations of xenophobia ===
CRectangle rectb(); // wrong!
{{main|Muslims in Western Europe|Multiculturalism}}
[[Islamic fundamentalism|Fundamentalist Islam]] has recently been acknowledged as a problem in Europe,<ref>{{cite news|date=[[27 February]] [[2006]]|title=Europe vs. Radical Islam by [[Francis Fukuyama]] |publisher=Policy Review |url=http://www.slate.com/id/2136964/}}</ref><ref>{{cite news|date=[[4 December]] [[2004]]|title=Stoned to death... why Europe is starting to lose its faith in Islam |publisher=Times Online|url=http://www.timesonline.co.uk/article/0,,3-1387077,00.html}}</ref> while disillusionment with [[multiculturalism]] is on the rise in Denmark.<ref>{{cite news|date=[[1 December]] [[2000]]|title=Denmark, the Euro, and fear of the Foreign |publisher=Policy Review |url=http://www.policyreview.org/dec00/Bering.html}}</ref> This was further fuelled by [[Mullah Krekar]] stating that "the number of Muslims is expanding like mosquitoes."<ref>{{cite news|date=[[2006-03-13]]|title=
Krekar claims Islam will win|url=
http://www.aftenposten.no/english/local/article1247400.ece|publisher=Aftenposten (English Edition)}}</ref><ref>{{cite news|date=[[2006-04-10]]|title=Libyan Leader Mu'ammar Al-Qadhafi: Europe and the U.S. Should Agree to Become Islamic or Declare War on the Muslims|url= http://www.memritv.org/Transcript.asp?P1=1121|publisher=Middle East Research Institute}}</ref> The [[UNCHR]] [[United Nations Special Rapporteur|Special Rapporteur]], on the other hand, saw [[xenophobia]] and [[racism]] in Europe as the root of the controversy,<ref>{{cite news|date=[[13 February]] [[2006]]|title=Racism, racial discrimination, xenophobia and all forms of discrimination (E/CN.4/2006/17)|publisher=UNCHR |url=http://ap.ohchr.org/documents/dpage_e.aspx?m=92}}</ref> particularly singling out Denmark.<ref>{{cite news|date=[[15 February]] [[2006]]|title=Denmark's new values |publisher=Guardian |url=http://www.guardian.co.uk/comment/story/0,,1709754,00.html}}</ref><ref>{{cite news|date=[[3 February]] [[2001]]|title=Second reprt on Denmark |publisher=European Commission against Racism and Intolerance |url=http://www.coe.int/t/e/human_rights/ecri/1-ecri/2-country-by-country_approach/Denmark/Denmark_CBC_2.asp}}</ref><ref>{{cite news|date=[[1 June]] [[2001]]|title=Cultural racism: something rotten in the state of Denmark? |publisher=Social & Cultural Geography, Volume 2, Number 2, Karen Wren |url=http://taylorandfrancis.metapress.com/link.asp?id=fvw7tvjel8rqq04j}}</ref>


=== Allegations of "agendas" ===
====Agendas in the West====
Some commentators see the publications of the cartoons and the riots that took place in response, as part of a coordinated effort to show Muslims and Islam in a bad light, thus influencing public opinion in the West in aid of various political projects, for example to support further military intervention in the Middle East.<ref>{{cite news|date=[[23 March]] [[2006]]|title=Islam and globanalisation|publisher=Al-Ahram|url=http://www.irna.ir/en/news/view/line-22/0601317044194736.htm}}</ref><ref>{{cite news|date=[[23 March]] [[2006]]|title=Rotten in Denmark |publisher=antiwar|url=http://antiwar.com/justin/?articleid=8512}}</ref> Most commentators in Europe framed the dispute as one between Islam and freedom of expression, which was a useful banner "under which the most diverse sectors of society can unite in the name of ‘European values’: [[feminist]]s and [[Christian conservative]]s, [[social democrat]]s and [[neoliberal]]s, [[nationalist]]s and [[multiculturalist]]s, [[civil rights]] activists and consumption-oriented [[hedonist]]s."


The controversy was used to highlight a supposedly irreconcilable rift between Europeans and Islam - as the journalist Andrew Mueller put it: "I am concerned that the ridiculous, disproportionate reaction to some unfunny sketches in an obscure Scandanavian newspaper may confirm that ... Islam and the West are fundamentally irreconcilable"<ref>{{Cited in The God Delusion by Richard Dawkins (2006) - p26}}</ref> - and many demonstrations in the Middle-East were encouraged by the regimes there for their own purposes. Different groups used this tactic for different purposes, some more explicitly than others: for example [[Nativism (politics)|anti-immigrant]] groups, nationalists, feminists, [[Classical liberalism|classical liberals]] and national governments.<ref>{{cite news|date=May/June [[2006]]|title=‘The journalists of Jyllands-Posten are a bunch of reactionary provocateurs’ The Danish cartoon controversy and the self-image of Europe |publisher=Radical Phillosophy|author= Heiko Henkel|url=http://www.radicalphilosophy.com/default.asp?channel_id=2187&editorial_id=21398}}</ref>


Default constructor
Muslim critics have also accused the west, in particular the EU, of double standards in adopting laws that outlaw [[Holocaust denial]]. Denmark, along with Britain and Sweden, have particularly libertarian traditions concerning Holocaust denial and pressed for wording in a recent EU legislation that would avoid criminalizing debates about the Holocaust and would ensure that films and plays about the Holocaust would not be censored.<ref>{{cite news|date=[[2007-04-19]]|title=EU adopts measure outlawing Holocaust denial |publisher=International Herald Tribune|url=http://www.iht.com/articles/2007/04/19/news/eu.php}}</ref>
If you do not declare any constructors in a class definition, the compiler assumes the class to have a default constructor with no arguments. Therefore, after declaring a class like this one:
class CExample {
public:
int a,b,c;
void multiply (int n, int m) { a=n; b=m; c=a*b; };
};


==== Alleged Zionist agenda ====
Among others,<ref>{{cite news|date=[[2 March]] [[2006]]|title=Qatari University Lecturer Ali Muhi Al-Din Al-Qardaghi: Muhammad Cartoon Is a Jewish Attempt to Divert European Hatred from Jews to Muslims|publisher=Al-Jazeera/MemriTV|url=http://www.memritv.org/Transcript.asp?P1=1030}}</ref> [[Iran]]'s supreme leader Ayatollah [[Ali Khamenei]] blamed a "Zionist [[Conspiracy theory|conspiracy]]" for the row over the cartoons.<ref>{{cite news|date=[[7 February]] [[2006]]|title=Cartoons 'part of Zionist plot'|publisher=Guardian|url=http://www.guardian.co.uk/cartoonprotests/story/0,,1704174,00.html}}</ref> The [[Palestinian]] envoy to Washington alleged the [[Likud]] party concocted distribution of Muhammad caricatures worldwide in a bid to create a clash between the West and the Muslim world.<ref>{{cite news|date=[[13 February]] [[2006]]|title=PA: Likud behind Muhammad cartoons|publisher=ynet|url=http://www.ynetnews.com/articles/0,7340,L-3215284,00.html}}</ref>


The compiler assumes that CExample has a default constructor, so you can declare objects of this class by simply declaring them without any arguments:
====Islamist or Mideast regime agendas====
Other commentators see [[Islamists]] jockeying for influence<ref>{{cite news|date=[[20 February]] [[2006]]|title=The Cartoon Jihad-The Muslim Brotherhood's project for dominating the West.|publisher=Weekly Standard|url=http://www.weeklystandard.com/Content/Public/Articles/000/000/006/704xewyj.asp?pg=1}}</ref> both in Europe<ref>{{cite news|date=[[23 February]] [[2006]]|title=Behind the cartoon war: radical clerics competing for followers|publisher=Christian Science Monitor|url=
http://csmweb2.emcweb.com/2006/0223/p09s01-coop.html?s=widep
}}</ref> and the [[Ummah|Islamic Ummah]],<ref>{{cite news|date=[[23 March]] [[2006]]|title=
Islamic Activism Sweeps Saudi Arabia|publisher=Washington Post|url=
http://www.washingtonpost.com/wp-dyn/content/article/2006/03/22/AR2006032202305.html}}</ref> who tried (unsuccessfully) to widen the split between the USA and Europe, and simultaneously bridge the split between the [[Sunnis]] and the [[Shia]].<ref>{{cite news|date=[[7 February]] [[2006]]|title=The Cartoon Backlash: Redefining Alignments|publisher=Stratfor|url=http://www.stratfor.com/products/premium/read_article.php?id=261960}}</ref>
<!--
=== Middle Eastern regimes' involvement ===
-->


CExample ex;
Regimes in the Middle East have been accused of taking advantage of the controversy, and adding to it, in order to demonstrate their Islamic credentials, distracting from their failures by setting up an external enemy,<ref>{{cite news|date=[[8 February]] [[2006]]|title=Cartoons Tap Into Deep-Seated Grievances|publisher=Forbes|url=http://www.forbes.com/business/2006/02/27/middle-east-cartoons_cx_0227oxford.html}}</ref>
<ref>{{cite news|date=[[1 February]] [[2006]]|title=En uhellig alliance har bragt konflikten om det hellige ud af kontrol«|publisher=Information|url=http://www.information.dk/InfWebsite/FremvisningPHP/Webavis/WAvPrint.php?pWAvVis=1241}} {{da icon}}</ref>
<ref>{{cite news|date=[[9 February]] [[2006]]|title=Opportunists Make Use of Cartoon Protests|publisher=Washington Times|url=http://www.washingtonpost.com/wp-dyn/content/article/2006/02/08/AR2006020802296_pf.html}}</ref> and "(using) the cartoons [...] as a way of showing that the expansion of freedom and democracy in their countries would lead inevitably to the denigration of Islam."<ref>{{cite news|date=[[11 February]] [[2006]]|title=Clash of Civilization|publisher=WallStreetJournal|url=http://www.opinionjournal.com/weekend/hottopic/?id=110007956}}</ref> [[Mahmoud Ahmadinejad]] announced a Holocaust Conference, supported<ref>{{cite news|date=[[16 February]] [[2006]]|title= Iran plans Holocaust conference|publisher=CNN|url=http://edition.cnn.com/2006/WORLD/meast/01/15/iran.holocaust/}}</ref> by the [[Organization of the Islamic Conference|OIC]], to uncover what he called the "myth" used to justify the creation of Israel.<ref>{{cite news|date=[[16 January]] [[2006]]|title=Tehran faces backlash over conference to question Holocaust |publisher=Guardian|url=http://www.guardian.co.uk/iran/story/0,12858,1687134,00.html}}</ref> Ahmadinejad started voicing doubt about the veracity of the holocaust at the same<ref>{{cite news|date=[[16 January]] [[2006]]|title=Iranian president says Israel should be moved to Europe |publisher=USAToday|url=http://www.usatoday.com/news/world/2005-12-09-iran-israel_x.htm}}</ref> [[Organization of the Islamic Conference|OIC]] conference in Mecca that served to spread the [[Akkari-Laban dossier]] to leaders of the Muslim world.<ref>{{cite news|title= How a meeting of leaders in Mecca set off the cartoon wars around the world|publisher=The Independent|date=[[2006-02-10]]|url=http://news.independent.co.uk/world/middle_east/article344482.ece}}</ref>


===Alleged political correctness===
Critics of [[political correctness]] see the cartoon controversy as a sign that attempts at judicial codification of such concepts as [[respect]], [[tolerance]] and [[offense]] have backfired on their advocates, "leaving them without a leg to stand on"<ref>{{cite news|date=[[13 February]] [[2006]]|title=Respectful Cultures & Disrespectful Cartoons|publisher=Counterpunch News|url=http://www.counterpunch.org/neumann02132006.html}}</ref> and in retreat again:


But as soon as you declare your own constructor for a class, the compiler no longer provides an implicit default constructor. So you have to declare all objects of that class according to the constructor prototypes you defined for the class:
{{quotation|The issue will almost certainly lead to a revisiting of the lamentable laws against "hate speech" in Europe, and with any luck to a debate on whether these laws are more likely to destroy public harmony than encourage it. Muslim activists are finding out why getting into a negative-publicity fight is as inadvisable as wrestling with a pig: You get dirty and the pig enjoys it.|<ref>{{cite news|date=[[13 February]] [[2006]]|title=The Mountain Comes to Muhammad|publisher=Reason Magazine|url=http://www.reason.com/links/links020306.shtml}}</ref>}}


class CExample {
== In popular culture ==
public:
int a,b,c;
CExample (int n, int m) { a=n; b=m; };
void multiply () { c=a*b; };
};


The [[South Park]] episodes ''[[Cartoon Wars Part I|Cartoon Wars (I]] [[Cartoon Wars Part II|and II)]]'' parodied this event.


Here we have declared a constructor that takes two parameters of type int. Therefore the following object declaration would be correct:
== Comparable references ==
{{main|Freedom of speech versus blasphemy}}


CExample ex (2,3);
Numerous comparisons have been offered in public discourse comparing earlier controversies over propriety of speech and art with the controversy that surrounded the ''Jyllands-Posten'' cartoons. Some examples include:
* ''[[Gerhard Haderer|The Life of Jesus]]'' (book, 2005, Greece)
But,
* ''[[Jerry Springer - The Opera]]'' (musical, 2005, Britain)
CExample ex;
* ''[[Bloody Mary (South Park)|Bloody Mary]]'' (TV, 2005, United States, [[New Zealand]], and Australia)
* ''[[Behzti]] (play, 2004, United Kingdom)''
* ''[[Submission (film)|Submission]]'' (short film, 2004, Netherlands)
* ''[[Snow White and The Madness of Truth]]'' (installation, 2004, Sweden)
* ''[[Ecce Homo (exhibition)|Ecce Homo]]'' (exhibition, 2000, Europe)
* ''[[Sensation exhibition|Sensation]]'' (exhibition, 1999, London and New York)
* ''[[Corpus Christi (play)|Corpus Christi]]'' (play, 1998, United States)
* ''[[United States Supreme Court building#Miscellaneous|Great Lawgivers]]'' (frieze, 1997, Washington D.C.)
* ''[[Tatiana Soskin]]'' (drawing, 1997, Israel)
* ''[[Taslima Nasrin#Biography|Taslima Nasrin]]'' (newspaper, 1994, Bangladesh)
* ''[[Piss Christ]]'' (photo, 1989, United States)
* ''[[The Satanic Verses (novel)|The Satanic Verses]]'' (novel, 1988, Global)
* ''[[The Last Temptation of Christ]]'' (film, 1988, United States and Europe)
* ''[[The Calcutta Quran Petition]]'' (court case, 1985, India)
* ''[[Monty Python's Life of Brian|Life of Brian]]'' (film, 1979, United States and Europe)
* ''[[James Kirkup|The Love That Dares to Speak Its Name]]'' (poem, 1977, United Kingdom)
* ''[[Mohammad, Messenger of God (film)|Mohammad, Messenger of God]]'' (film, 1977, United States, Libya, UK and Lebanon)


== See also ==
* [[Blasphemy laws in Islamic Republic of Iran]]
* [[Religion in Denmark]]
* [[Censorship by religion]]
* [[Clash of Civilizations]]
* [[Dialogue Among Civilizations]]
* [[Controversial newspaper caricatures]]
* [[Freedom of the press]]
* [[Freedom of speech and freedom of the press in Denmark]]
* [[Freedom of speech versus blasphemy]]
* [[Internet censorship in Pakistan]]
* [[Iran Holocaust Cartoons Contest]]
* [[Government-organized demonstration]]
* [[Islam in Denmark]]
* [[Islamist demonstration outside Danish Embassy in London]]
* [[Pope Benedict XVI Islam controversy]]
* [[Rakyat Merdeka dingo cartoon controversy]]
* [[Separation of church and state]]
* [[Strelnikoff Mary of Help of Brezje controversy]]
* [[Lars Vilks#Muhammad drawings controversy]]


Would not be correct, since we have declared the class to have an explicit constructor, thus replacing the default constructor.
== References ==
{{Reflist|2}}


But the compiler not only creates a default constructor for you if you do not specify your own. It provides three special member functions in total that are implicitly declared if you do not declare your own. These are the copy constructor, the copy assignment operator, and the default destructor.
== External links ==
===Primary sources===
* {{PDFlink|[http://www.filtrat.dk/grafik/Letterfromambassadors.pdf The letter to the Prime Minister from the Muslim ambassadors]|74.5&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 76389 bytes -->}}
* {{PDFlink|[http://gfx-master.tv2.dk/images/Nyhederne/Pdf/side3.pdf The response to the letters from the ambassadors]|545&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 558231 bytes -->}}
* {{PDFlink|[http://www1.jp.dk/indland/doku/jp_aabent_brev.pdf First open letter in Arabic to the Muslims of Saudi Arabia from Jyllands-Posten]|18.2&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 18709 bytes -->}}
* Second [[open letter]] to the Muslims of Saudi Arabia from Jyllands-Posten
** {{PDFlink|[http://www1.jp.dk/indland/doku/jp_brev_arabisk.pdf In Arabic]|68.7&nbsp;[[Kibibyte|KiB]]<!-- application/pdf, 70448 bytes -->}}
** [http://www.jp.dk/meninger/ncartikel:aid=3527646 In English]
* [http://www.ekstrabladet.dk/VisArtikel.iasp?PageID=329877 Photocopies of the Imams' dossier]
* [http://www.um.dk/en/servicemenu/News/FrontPageNews/DrawingsInADanishNewspaperQuestionsAndAnswers.htm The Danish Foreign ministry, rebutting rumours that were spread via SMS and word-of-mouth]
* {{PDFlink|1=[http://www.rigsadvokaten.dk/ref.aspx?id=890 The Danish Director of Public Prosecutions: Decision on possible criminal proceedings in the case of Jyllands-Posten's article]}}
* [http://aarhus.byret.dk/?id=30550 Official press release of the Aarhus court] (in Danish)
====Islamic views====
* [http://www.duaatalislam.com/english.htm Declaration on behalf of Muslim Religious Leaders] signed by many [http://www.duaatalislam.com/sge.htm notable clerics and scholars].
* [http://www.amrkhaled.net/articles/articles1244.html Amr khaled - A message to the World]
* [http://www.islamfrominside.com/Pages/Commentary/Danish%20cartoons%20and%20desacralization.html Danish cartoons and sacred imagery]
* [http://jurist.law.pitt.edu/forumy/2006/02/danish-trojan-horse-law-and-muhammad.php A Danish Trojan Horse: Law and the Muhammad Cartoons], [[JURIST]]
* [http://jurist.law.pitt.edu/forumy/2006/03/tolerance-on-trial-why-we-reprinted.php Tolerance on Trial: Why We Reprinted the Danish Cartoons] (op-ed by the publisher of the English-language ''Yemen Observer'' newspaper), [[JURIST]]
* [http://islamselect.com/naby/index.php?pg=en Support Your Prophet] ''A declaration condemning the attack by reporters from Denmark and Norway against the Prophet, sallallaahu ‘alayhi wa sallam''.
* [http://www.memri.org/bin/opener_latest.cgi?ID=SD108906 MEMRI translation of Friday sermon] by Sheikh Yousef Al-Qaradhawi, head of [[European Council for Fatwa and Research]]
* [http://taylorandfrancis.metapress.com/index/V10M3R55540Q668P.pdf The Danish caricatures seen from the Arab world] by Ana Belén Soage, ''Totalitarian Movements and Political Religions'' 7(3).


The copy constructor and the copy assignment operator copy all the data contained in another object to the data members of the current object. For CExample, the copy constructor implicitly declared by the compiler would be something similar to:
====Non-Islamic views====
* [http://www.taz.de/pt/2006/02/06/a0132.1/text Was nun, ferner Bärtiger?] (''What's next, bearded one?'') by [[Sonia Mikich]], ''[[die tageszeitung]]'', [[February 6]], 2006 {{de icon}} - [http://www.signandsight.com/features/597.html English translation] at signandsight.com
* [http://www.project-syndicate.org/commentary/dahrendorf55/English Today’s Counter-Enlightenment] by [[Ralf Dahrendorf]], [[Project Syndicate]]
* [http://www.opendemocracy.net/articles/ViewPopUpArticle.jsp?id=6&articleId=3247 A post-Satanic journey] by [[Ehsan Masood]], [[openDemocracy]], [[July 2]], 2006


CExample::CExample (const CExample& rv) {
===Press reviews===
a=rv.a; b=rv.b; c=rv.c;
* [http://news.bbc.co.uk/2/hi/middle_east/4674864.stm BBC, Q&A Depicting the Prophet Muhammad]
}
* [http://www.guardian.co.uk/cartoonprotests/0,,1703418,00.html The Guardian special reports: cartoon protests]
* [http://news.bbc.co.uk/2/hi/middle_east/4677464.stm World press review by BBC Monitoring]
* [http://news.bbc.co.uk/1/hi/world/europe/4676632.stm BBC Viewpoints]
* [http://www.signandsight.com/features/590.html ''The twelve Muhammad cartoons''] a European press review at signandsight.com


===Video===
* [http://littlegreenfootballs.com/weblog/video/20060203LondonProtest.wmv London demonstration in front of the Danish embassy 3 Feb 2006]
* [http://switch5.castup.net/frames/20041020_MemriTV_Popup/video_480x360.asp?ai=214&ar=1025wmv&ak=null Protesters Burn European Embassies, Consulates, Churches in Damascus and Beirut February 4-5 2006]
* [http://video.google.com/videoplay?docid=-2857772804755452693 Interview with American Muslim Hamza Yusuf] on Danish [[News program|news show]] ''Deadline''
* [http://www.bbc.co.uk/newsa/n5ctrl/progs/06/hardtalk/rose_laban03feb.ram BBC HARDtalk: Ahmad Abu Laban and Fleming Rose, 8 February 2006]
* [http://ksgaccman.harvard.edu/iop/events_forum_video.asp?ID=2961 JFK Jr. Forum cartoons controversy discussion] at [[Harvard University]] by Shahab Ahmed, Jocelyne Cesari, Father J. Bryan Hehir, Dr. Joseph S. Nye Jr. ([[RealPlayer]] stream)
*[http://www.channel4.com/more4/news/news-opinion-feature.jsp?id=562 More4 News report] on the French magazine, Charlie Hebdo, that reprinted the cartoons of the prophet Mohammed being cleared of defamation.


Therefore, the two following object declarations would be correct:
===Images===
{{Commons|Muhammad}}
* [http://blog.newspaperindex.com/2005/12/10/un-to-investigate-jyllands-posten-racism/ The 12 cartoons in full size at Newspaper Index]
* [http://epaper.jp.dk/30-09-2005/demo/JP_04-03.html The page of Jylland-Posten that contains Muhammad cartoons]
* [http://www.dagbladet.no/nyheter/2006/02/04/456821.html?i=1 Picture series - Burning of the Danish embassy in Syria]
* [http://www.cagle.com/news/Muhammad/main.asp More editorial cartoons, including some depicting Muhammed, mainly in response to the protests of the original drawings]
* [http://www.prophetcartoons.com/ Prophet cartoons and comments on the controversy]


CExample ex (2,3);
===Online petitions===
CExample ex2 (ex); // copy constructor (data copied from ex)
* [http://www.rezgar.com/camp/i.asp?id=50 It is Enough Now] Letter for reconciliation in Arabic, Danish and English
* [http://www.anotherdenmark.org A letter from Another Denmark] Another Danish petition for reconciliation
* [http://www.ya-mohammed.com/ An online protest against cartoons of Prophet Muhammad] A site that condemns the Jyllands Posten cartoons and invites others to protest by submitting their [[e-mail address]]es. As of April 8, 2006 more than 145,000 individuals had entered their addresses.
* [http://www.opendemocracy.net/servlet/DoVote?pollId=10&bd=true&bdID=5&curbdID=8 Bad Democracy Award] for [[March 2006]]. Abu Laban won by a landslide.


===Other sources===
* [http://www.lastingnews.com/maps/cartoons_protests.html Cartoons riots Google Maps mashup] A mashup displaying places where protests, riots and fatalities occurred during the Mohamed cartoons row
* [http://www.jcpa.org/phas/phas-043-gerstenfeld.htm The Mohammed-Cartoon Controversy, Israel, and the Jews: A Case Study] by [[Manfred Gerstenfeld]] of the [[Jerusalem Center for Public Affairs]]
* [http://www.weeklystandard.com/Content/Public/Articles/000/000/006/697dhzzd.asp Weekly Standard Reprint of Danish Cartoons] by [[William Kristol]]


[[Category:Jyllands-Posten cartoons controversy|*]]
[[Category:Islam-related controversies]]
[[Category:Transgressive art]]
[[Category:Freedom of expression]]
[[Category:Muhammad]]
[[Category:Boycotts of countries]]


Pointers to classes
[[ar:رسوم كاريكاتورية مسيئة للنبي محمد في صحيفة يولاندس بوستن الدانماركية]]
It is perfectly valid to create pointers that point to classes. We simply have to consider that once declared, a class becomes a valid type, so we can use the class name as the type for the pointer. For example:
[[bs:12 crteža Muhameda]]
CRectangle * prect;
[[cs:Kauza karikatur proroka Mohameda]]
[[cy:Dadl cartwnau Muhammad Jyllands-Posten]]

[[da:Muhammed-tegningerne]]

[[de:Das Gesicht Mohammeds]]
is a pointer to an object of class CRectangle.
[[es:Caricaturas de Mahoma en el periódico Jyllands-Posten]]

[[fr:Caricatures de Mahomet du journal Jyllands-Posten]]
As it happened with data structures, in order to refer directly to a member of an object pointed by a pointer we can use the arrow operator (->) of indirection. Here is an example with some possible combinations:
[[ko:윌란스 포스텐 지 무함마드 만평 논란]]

[[id:Karikatur Nabi Muhammad Jyllands-Posten]]
// pointer to classes example
[[it:Caricature di Maometto sul Jyllands-Posten]]
#include <iostream>
[[he:פרשת קריקטורות מוחמד]]
using namespace std;
[[la:Jyllands-Posten ob illustrationes Mochameti (Muhammedi) controversia]]

[[lb:Mohammed-Karikature vu Jyllands-Posten]]
class CRectangle {
[[lt:Mahometo atvaizdas]]
int width, height;
[[nl:Cartoons over Mohammed in Jyllands-Posten]]
public:
[[ja:ムハンマド風刺漫画掲載問題]]
void set_values (int, int);
[[no:Muhammed-karikaturene]]
int area (void) {return (width * height);}
[[pl:Karykatury Mahometa]]
};
[[pt:Polêmica dos cartoons da Jyllands-Posten sobre Maomé]]

[[ru:Карикатурный скандал 2005—2006 годов]]
void CRectangle::set_values (int a, int b) {
[[simple:Jyllands-Posten Muhammad cartoons controversy]]
width = a;
[[sl:Sporne karikature Mohameda (Jyllands-Posten)]]
height = b;
[[sr:Карикатуре Мухамеда]]
}
[[fi:Muhammad-pilapiirrosjupakka]]

[[sv:Muhammedbilderna i Jyllands-Posten]]
int main () {
[[vi:Vụ biếm họa Muhammad]]
CRectangle a, *b, *c;
[[tr:Danimarka Karikatür Krizi]]
CRectangle * d = new CRectangle[2];
[[zh:日德蘭郵報穆罕默德漫畫事件]]
b= new CRectangle;
c= &a;
a.set_values (1,2);
b->set_values (3,4);
d->set_values (5,6);
d[1].set_values (7,8);
cout << "a area: " << a.area() << endl;
cout << "*b area: " << b->area() << endl;
cout << "*c area: " << c->area() << endl;
cout << "d[0] area: " << d[0].area() << endl;
cout << "d[1] area: " << d[1].area() << endl;
delete[] d;
delete b;
return 0;
}
a area: 2
*b area: 12
*c area: 2
d[0] area: 30
d[1] area: 56


Next you have a summary on how can you read some pointer and class operators (*, &, ., ->, [ ]) that appear in the previous example:

expression can be read as
*x pointed by x
&x address of x
x.y member y of object x
x->y member y of object pointed by x
(*x).y member y of object pointed by x (equivalent to the previous one)
x[0] first object pointed by x
x[1] second object pointed by x
x[n] (n+1)th object pointed by x


Be sure that you understand the logic under all of these expressions before proceeding with the next sections. If you have doubts, read again this section and/or consult the previous sections about pointers and data structures.


Classes defined with struct and union
Classes can be defined not only with keyword class, but also with keywords struct and union.
The concepts of class and data structure are so similar that both keywords have in C++ the exact same functionality except that the members of classes declared with keyword struct have public access by default, instead of private access, as classes declared with keyword class have. That is the only difference. For all other purposes both keywords are equivalent.

The concept under unions is different from than of struct and class, since unions only store one data member at a time, but they are also classes and thus can also hold function members. The default access in union classes is public.

Revision as of 20:54, 30 August 2007

Classes (I) Published by Juan Soulie Last update on May 7, 2007 at 9:30am

A class is an expanded concept of a data structure: instead of holding only data, it can hold both data and functions. An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.

Classes are generally declared using the keyword class, with the following format:


class class_name {

 access_specifier_1:
   member1;
 access_specifier_2:
   member2;
 ...
 } object_names;

Where class_name is a valid identifier for the class, object_names is an optional list of names for objects of this class. The body of the declaration can contain members, that can be either data or function declarations, and optionally access specifiers.

All is very similar to the declaration on data structures, except that we can now include also functions and members, but also this new thing called access specifier. An access specifier is one of the following three keywords: private, public or protected. These specifiers modify the access rights that the members following them acquire:


private members of a class are accessible only from within other members of the same class or from their friends. protected members are accessible from members of their same class and from their friends, but also from members of their derived classes. Finally, public members are accessible from anywhere where the object is visible. By default, all members of a class declared with the class keyword have private access for all its members. Therefore, any member that is declared before one other class specifier automatically has private access. For example:

class CRectangle {

   int x, y;
 public:
   void set_values (int,int);
   int area (void);
 } rect;


Declares a class (i.e., a type) called CRectangle and an object (i.e., a variable) of this class called rect. This class contains four members: two data members of type int (member x and member y) with private access (because private is the default access level) and two member functions with public access: set_values() and area(), of which for now we have only included their declaration, not their definition.

Notice the difference between the class name and the object name: In the previous example, CRectangle was the class name (i.e., the type), whereas rect was an object of type CRectangle. It is the same relationship int and a have in the following declaration:

int a;


where int is the type name (the class) and a is the variable name (the object).

After the previous declarations of CRectangle and rect, we can refer within the body of the program to any of the public members of the object rect as if they were normal functions or normal variables, just by putting the object's name followed by a dot (.) and then the name of the member. All very similar to what we did with plain data structures before. For example:

rect.set_values (3,4); myarea = rect.area();


The only members of rect that we cannot access from the body of our program outside the class are x and y, since they have private access and they can only be referred from within other members of that same class.

Here is the complete example of class CRectangle:

// classes example

  1. include <iostream>

using namespace std;

class CRectangle {

   int x, y;
 public:
   void set_values (int,int);
   int area () {return (x*y);}

};

void CRectangle::set_values (int a, int b) {

 x = a;
 y = b;

}

int main () {

 CRectangle rect;
 rect.set_values (3,4);
 cout << "area: " << rect.area();
 return 0;

}

area: 12


The most important new thing in this code is the operator of scope (::, two colons) included in the definition of set_values(). It is used to define a member of a class from outside the class declaration itself.

You may notice that the definition of the member function area() has been included directly within the definition of the CRectangle class given its extreme simplicity, whereas set_values() has only its prototype declared within the class, but its definition is outside it. In this outside declaration, we must use the operator of scope (::) to specify that we are defining a function that is a member of the class CRectangle and not a regular global function.

The scope operator (::) specifies the class to which the member being declared belongs, granting exactly the same scope properties as if this function definition was directly included within the class definition. For example, in the function set_values() of the previous code, we have been able to use the variables x and y, which are private members of class CRectangle, which means they are only accessible from other members of their class.

The only difference between defining a class member function completely within its class and to include only the prototype and later its definition, is that in the first case the function will automatically be considered an inline member function by the compiler, while in the second it will be a normal (not-inline) class member function, which in fact supposes no difference in behavior.

Members x and y have private access (remember that if nothing else is said, all members of a class defined with keyword class have private access). By declaring them private we deny access to them from anywhere outside the class. This makes sense, since we have already defined a member function to set values for those members within the object: the member function set_values(). Therefore, the rest of the program does not need to have direct access to them. Perhaps in a so simple example as this, it is difficult to see an utility in protecting those two variables, but in greater projects it may be very important that values cannot be modified in an unexpected way (unexpected from the point of view of the object).

One of the greater advantages of a class is that, as any other type, we can declare several objects of it. For example, following with the previous example of class CRectangle, we could have declared the object rectb in addition to the object rect:

// example: one class, two objects

  1. include <iostream>

using namespace std;

class CRectangle {

   int x, y;
 public:
   void set_values (int,int);
   int area () {return (x*y);}

};

void CRectangle::set_values (int a, int b) {

 x = a;
 y = b;

}

int main () {

 CRectangle rect, rectb;
 rect.set_values (3,4);
 rectb.set_values (5,6);
 cout << "rect area: " << rect.area() << endl;
 cout << "rectb area: " << rectb.area() << endl;
 return 0;

}

rect area: 12

rectb area: 30


In this concrete case, the class (type of the objects) to which we are talking about is CRectangle, of which there are two instances or objects: rect and rectb. Each one of them has its own member variables and member functions.

Notice that the call to rect.area() does not give the same result as the call to rectb.area(). This is because each object of class CRectangle has its own variables x and y, as they, in some way, have also their own function members set_value() and area() that each uses its object's own variables to operate.

That is the basic concept of object-oriented programming: Data and functions are both members of the object. We no longer use sets of global variables that we pass from one function to another as parameters, but instead we handle objects that have their own data and functions embedded as members. Notice that we have not had to give any parameters in any of the calls to rect.area or rectb.area. Those member functions directly used the data members of their respective objects rect and rectb.


Constructors and destructors Objects generally need to initialize variables or assign dynamic memory during their process of creation to become operative and to avoid returning unexpected values during their execution. For example, what would happen if in the previous example we called the member function area() before having called function set_values()? Probably we would have gotten an undetermined result since the members x and y would have never been assigned a value. In order to avoid that, a class can include a special function called constructor, which is automatically called whenever a new object of this class is created. This constructor function must have the same name as the class, and cannot have any return type; not even void.

We are going to implement CRectangle including a constructor:

// example: class constructor

  1. include <iostream>

using namespace std;

class CRectangle {

   int width, height;
 public:
   CRectangle (int,int);
   int area () {return (width*height);}

};

CRectangle::CRectangle (int a, int b) {

 width = a;
 height = b;

}

int main () {

 CRectangle rect (3,4);
 CRectangle rectb (5,6);
 cout << "rect area: " << rect.area() << endl;
 cout << "rectb area: " << rectb.area() << endl;
 return 0;

}

rect area: 12

rectb area: 30


As you can see, the result of this example is identical to the previous one. But now we have removed the member function set_values(), and have included instead a constructor that performs a similar action: it initializes the values of x and y with the parameters that are passed to it.

Notice how these arguments are passed to the constructor at the moment at which the objects of this class are created:

CRectangle rect (3,4); CRectangle rectb (5,6);


Constructors cannot be called explicitly as if they were regular member functions. They are only executed when a new object of that class is created.

You can also see how neither the constructor prototype declaration (within the class) nor the latter constructor definition include a return value; not even void.

The destructor fulfills the opposite functionality. It is automatically called when an object is destroyed, either because its scope of existence has finished (for example, if it was defined as a local object within a function and the function ends) or because it is an object dynamically assigned and it is released using the operator delete.

The destructor must have the same name as the class, but preceded with a tilde sign (~) and it must also return no value.

The use of destructors is especially suitable when an object assigns dynamic memory during its lifetime and at the moment of being destroyed we want to release the memory that the object was allocated.

// example on constructors and destructors

  1. include <iostream>

using namespace std;

class CRectangle {

   int *width, *height;
 public:
   CRectangle (int,int);
   ~CRectangle ();
   int area () {return (*width * *height);}

};

CRectangle::CRectangle (int a, int b) {

 width = new int;
 height = new int;
 *width = a;
 *height = b;

}

CRectangle::~CRectangle () {

 delete width;
 delete height;

}

int main () {

 CRectangle rect (3,4), rectb (5,6);
 cout << "rect area: " << rect.area() << endl;
 cout << "rectb area: " << rectb.area() << endl;
 return 0;

}

rect area: 12

rectb area: 30



Overloading Constructors Like any other function, a constructor can also be overloaded with more than one function that have the same name but different types or number of parameters. Remember that for overloaded functions the compiler will call the one whose parameters match the arguments used in the function call. In the case of constructors, which are automatically called when an object is created, the one executed is the one that matches the arguments passed on the object declaration: // overloading class constructors

  1. include <iostream>

using namespace std;

class CRectangle {

   int width, height;
 public:
   CRectangle ();
   CRectangle (int,int);
   int area (void) {return (width*height);}

};

CRectangle::CRectangle () {

 width = 5;
 height = 5;

}

CRectangle::CRectangle (int a, int b) {

 width = a;
 height = b;

}

int main () {

 CRectangle rect (3,4);
 CRectangle rectb;
 cout << "rect area: " << rect.area() << endl;
 cout << "rectb area: " << rectb.area() << endl;
 return 0;

}

rect area: 12

rectb area: 25


In this case, rectb was declared without any arguments, so it has been initialized with the constructor that has no parameters, which initializes both width and height with a value of 5.

Important: Notice how if we declare a new object and we want to use its default constructor (the one without parameters), we do not include parentheses ():

CRectangle rectb; // right CRectangle rectb(); // wrong!



Default constructor If you do not declare any constructors in a class definition, the compiler assumes the class to have a default constructor with no arguments. Therefore, after declaring a class like this one: class CExample {

 public:
   int a,b,c;
   void multiply (int n, int m) { a=n; b=m; c=a*b; };
 };


The compiler assumes that CExample has a default constructor, so you can declare objects of this class by simply declaring them without any arguments:

CExample ex;


But as soon as you declare your own constructor for a class, the compiler no longer provides an implicit default constructor. So you have to declare all objects of that class according to the constructor prototypes you defined for the class:

class CExample {

 public:
   int a,b,c;
   CExample (int n, int m) { a=n; b=m; };
   void multiply () { c=a*b; };
 };


Here we have declared a constructor that takes two parameters of type int. Therefore the following object declaration would be correct:

CExample ex (2,3);

But, CExample ex;


Would not be correct, since we have declared the class to have an explicit constructor, thus replacing the default constructor.

But the compiler not only creates a default constructor for you if you do not specify your own. It provides three special member functions in total that are implicitly declared if you do not declare your own. These are the copy constructor, the copy assignment operator, and the default destructor.

The copy constructor and the copy assignment operator copy all the data contained in another object to the data members of the current object. For CExample, the copy constructor implicitly declared by the compiler would be something similar to:

CExample::CExample (const CExample& rv) {

 a=rv.a;  b=rv.b;  c=rv.c;
 }


Therefore, the two following object declarations would be correct:

CExample ex (2,3); CExample ex2 (ex); // copy constructor (data copied from ex)



Pointers to classes It is perfectly valid to create pointers that point to classes. We simply have to consider that once declared, a class becomes a valid type, so we can use the class name as the type for the pointer. For example: CRectangle * prect;


is a pointer to an object of class CRectangle.

As it happened with data structures, in order to refer directly to a member of an object pointed by a pointer we can use the arrow operator (->) of indirection. Here is an example with some possible combinations:

// pointer to classes example

  1. include <iostream>

using namespace std;

class CRectangle {

   int width, height;
 public:
   void set_values (int, int);
   int area (void) {return (width * height);}

};

void CRectangle::set_values (int a, int b) {

 width = a;
 height = b;

}

int main () {

 CRectangle a, *b, *c;
 CRectangle * d = new CRectangle[2];
 b= new CRectangle;
 c= &a;
 a.set_values (1,2);
 b->set_values (3,4);
 d->set_values (5,6);
 d[1].set_values (7,8);
 cout << "a area: " << a.area() << endl;
 cout << "*b area: " << b->area() << endl;
 cout << "*c area: " << c->area() << endl;
 cout << "d[0] area: " << d[0].area() << endl;
 cout << "d[1] area: " << d[1].area() << endl;
 delete[] d;
 delete b;
 return 0;

}

a area: 2
  • b area: 12
  • c area: 2

d[0] area: 30 d[1] area: 56


Next you have a summary on how can you read some pointer and class operators (*, &, ., ->, [ ]) that appear in the previous example:

expression can be read as

  • x pointed by x

&x address of x x.y member y of object x x->y member y of object pointed by x (*x).y member y of object pointed by x (equivalent to the previous one) x[0] first object pointed by x x[1] second object pointed by x x[n] (n+1)th object pointed by x


Be sure that you understand the logic under all of these expressions before proceeding with the next sections. If you have doubts, read again this section and/or consult the previous sections about pointers and data structures.


Classes defined with struct and union Classes can be defined not only with keyword class, but also with keywords struct and union. The concepts of class and data structure are so similar that both keywords have in C++ the exact same functionality except that the members of classes declared with keyword struct have public access by default, instead of private access, as classes declared with keyword class have. That is the only difference. For all other purposes both keywords are equivalent.

The concept under unions is different from than of struct and class, since unions only store one data member at a time, but they are also classes and thus can also hold function members. The default access in union classes is public.