Keanehan dan keunikan yang ada di dunia

03 November 2009

Initialization of variables

When declaring a regular local variable, its value is by default undetermined. But you may want a variable to store a concrete value at the same moment that it is declared. In order to do that, you can initialize the variable. There are two ways to do this in C++:

The first one, known as c-like initialization, is done by appending an equal sign followed by the value to which the variable will be initialized:

type identifier = initial_value ;

For example, if we want to declare an int variable called a initialized with a value of 0 at the moment in which it is declared, we could write:

 
int a = 0;


The other way to initialize variables, known as constructor initialization, is done by enclosing the initial value between parentheses (()):

type identifier (initial_value) ;

For example:

 
int a (0); 


Both ways of initializing variables are valid and equivalent in C++.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// initialization of variables

#include 
using namespace std;

int main ()
{
  int a=5;               // initial value = 5
  int b(2);              // initial value = 2
  int result;            // initial value undetermined

  a = a + 3;
  result = a - b;
  cout << result;

  return 0;
}
  




Tags

10 fakta unik 12-12-2012 17 + 5 fakta unik 6 fakta unik 7 fakta unik 8 fakta unik 9 fakta unik adegan ranjang ajaib akhir zaman alien alien di bumi aljabar linear all about cinta aneh anime antivirus artis barat artis china artis dalam negri artis dunia artis hot artis india artis jepang artis lucu artis pendatang baru award babi aneh banci banten Belajar PHP bencong berita berita dewasa berita indonesia berita terbaru berita unik bertta bintang film porno bintang porno jepang blog tutorial bocah unik boneka terseram buaya panjang 12 m C++ cantik cari uang mudah cewek cantik cewek facebook cewek nekat cewek panggilan cewek rusia Cheerleader Contact curhat dapat uang 10 - 15 juta perbulan. desa terapung desain unik dewasa djarum black competition f facebook fb cewek cantik fenomena alam film film indonesia finalis miss indonesia 2013 foto artis foto HOT foto lucu foto panas foto unik ga gadis gadis cantik gambar artis lokal gambar artis luar gambar berbahaya gambar HOT gambar lucu gambar sexy gambar unik game game indonesia game seru hack handphone terbaru hewan aneh hewan berbahaya hewan unik honey moon Hujan yang aneh indonesia unik IT jadul jav java jepang jepang unik jual septic tank kamus bencong kamus waria kanibal karya unik keajaiban Tuhan keanehan dunia keberadaan alien kelakuan pria kesehatan keunikan alam keunikan hewan keunikan manusia kiamat kiamat 2012 koleksi foto tasya djerli komputer kota terunik kota unik kreatif kucing berdoa kuliner lab Algoritma laptop jadul lirik lagu lorong waktu luar biasa luna maya maho makanan makanan aneh makanan unik manusia hebat manusia liliput manusia raksasa manusia unik maria ozawa materi kuliah mengapa pesawat sukhoi jatuh? pramugari pesawat sukhoi mengerikan Mesin waktu mey meydiana sari miss banten miss indonesia miss indonesia 2013 miss indonesia meydi misteri mistis motivasi nekat payudara penampakan alien Penemuan pengetahuan umum penghargaan nobel penghasilan penyakit aneh penyebab pesawat sukhoi jatuh perwakilan banten pesawat sukhoi pesawat sukhoi jatuh pohon aneh pria maho ramalan dunia ramalan kiamat renungan reseller rin sakuragi rohani rumah unik sejarah sejarah windows selebritis septic tank septic tank biological septic tank fiberglas septic tank modern septic tank murah septictank bio seputar hantu seram sora aoi spiteng fiber spiteng fibreglass tahukah anda tangki septic tank tato 3D teknologi terbaru tikus jadi ayam tips and trik blog tips kesehatan tips unik tumbuhan unik tutorial facebook unik unik-unik video porno waria windows 8 wisata kuliner

TaTTiTTuT Blog Copyright © 2011 | Template created by O Pregador | Powered by Blogger