codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <fstream> class FileClient { protected: char* p; public: virtual void connect() = 0; void close(){} virtual void ping() { printf("%s : %s", "__FUNCTION__", p); } FileClient() { p = new char[10]; p[0] = '1'; } ~FileClient() { delete p; } }; class Client : public FileClient { FILE* hFile; public: Client() : hFile( NULL ) {}//кто обнулять будет? virtual void connect(){ //глупая функция путь к файлу и параметры следует передават ьв функцию а не забивать hFile = fopen("D:\\test.txt", "w"); } void ping() { char arr[] = { 0, 0, 5, 56, 12, 32 }; fwrite(arr, 1, sizeof(arr), hFile); FileClient::ping(); } ~Client() { if( p ) delete[] p; p = 0; if( hFile ) fclose(hFile); } }; int main() { FileClient* client = new Client; client->connect(); client->ping(); delete client; }
Private
[
?
]
Run code
Submit