27 Aralık 2016 Salı

C++ Dosya Okuma Yazma İşlemleri

ofstreamThis data type represents the output file stream and is used to create files and to write information to files.
ifstreamThis data type represents the input file stream and is used to read information from files.
fstreamThis data type represents the file stream generally, and has the capabilities of both ofstream and ifstream which means it can create files, write information to files, and read information from files.
ios::appAppend mode. All output to that file to be appended to the end.
ios::ateOpen a file for output and move the read/write control to the end of the file.
ios::inOpen a file for reading.
ios::outOpen a file for writing.
ios::truncIf the file already exists, its contents will be truncated before opening the file.





Dosya içinde Gezebilmek için ;


 These member functions are seekg ("seek get") for istream and seekp ("seek put") for ostream.


The seek direction can be ios::beg (the default) for positioning relative to the beginning of a stream, ios::cur for positioning relative to the current position in a stream or ios::end for positioning relative to the end of a stream.





// position to the nth byte of fileObject (assumes ios::beg)
fileObject.seekg( n );

// position n bytes forward in fileObject
fileObject.seekg( n, ios::cur );

// position n bytes back from end of fileObject
fileObject.seekg( n, ios::end );

// position at end of fileObject
fileObject.seekg( 0, ios::end );

Share:

VMWARE Sanal Makinede Ubuntu Açılmama Sorunu

Vmware makinede kurulu işletim sistemi ansızın kapandı vs. nedenlerden dolayı  ve açılamıyor ;

VMware “Cannot open the disk ‘XXXXXX.vmdk’ or one of the snapshot disks it depends on.


Uyarısı Alıyorsa  C:\Users\User\Documents\Virtual Machines\Ubuntu  altındaki   .lck uzantılı dosyaları silip tekrar açmaya çalısırsak düzelecektir
Share:

26 Aralık 2016 Pazartesi

C++ Inheritance (Miras Alma)

Türetilmiş bir sınıf, taban sınıfının özel olmayan tüm üyelerine erişebilir. Böylelikle türetilmiş sınıfların üye işlevleri tarafından erişilebilir olmamaları gereken taban sınıfı üyeler taban sınıfında özel olarak bildirilmelidir.



Share:

Class ve Struct Arasıdaki Farklar

  • Struct ve Class Arasındaki Fark : Yapılar bir değer türü, sınıflar ise bir referans türüdür. Referans tiplerinin sahip olduğu veriler, belleğin öbek (heap) adı verilen tarafında tutulurken, referansın adı, yığın (stack) adı verilen kısımda tutulur ve öbekteki verilerin bulunduğu adresi işaret eder. Ancak değer türleri, belleğin yığın kısmında tutulur. Sınıflara referans aracılığıyla ulaşılırken, yapılara ise doğrudan ulaşılır. Bu nedenle, yapı kullanımı sınıf kullanımına göre daha az maliyetlidir ve erişim hızı yüksektir.Bir sınıf oluşturulduğunda, bu, başka bir temel sınıftan kalıtım yolu ile türetilebilir ancak bir yapı başka bir yapı temel alınarak türetilemez.
  • Struct icindeki degiskenler defaultta PUBLİC iken ,Class icindeki degiskenler defaultta  PRIVATE tır                                                                                                                                             
    // Program 1
    #include
     
    class Test {
        int x; // x is private
    };
    int main()
    {
      Test t;
      t.x = 20; // compiler error because x is private
      getchar();
      return 0;
    }


  • Classlar Fonksiyon içerebilir
Share: