книги
авторы
Вход/Регистрация
Справочное руководство по C++
вернуться
Страустрап Бьярн
Шрифт:
Arial
Century
Courier
Georgia
Tahoma
Verdana
Times New Roman
-
+
}
derived::derived
{
cout ‹‹ "\tderived 1: this=" ‹‹ long(this) ‹‹ "\n";
if (this == 0) this = (derived*)43;
cout ‹‹ "\tderived 2: this=" ‹‹ long(this) ‹‹ "\n";
}
main
{
cout ‹‹ "base b;\n";
base b;
cout ‹‹ "new base;\n";
new base;
cout ‹‹ "derived d;\n";
derived d;
cout ‹‹ "new derived;\n";
new derived;
cout ‹‹ "new derived;\n";
new derived;
cout ‹‹ "at the end\n";
}
b8_3_3.cxx
#include ‹xstream.hxx›
extern void exit(int);
void error(char* s, char* s2)
{
cerr ‹‹ s ‹‹ " " ‹‹ s2 ‹‹ "\n";
exit(1);
}
main(int argc, char* argv[])
{
if (argc != 3) error ("wrong number of arguments",");
filebuf f1;
if (f1.open(argv[1],input) == 0)
error("cannot open input file",argv[1]);
istream from(&f1);
filebuf f2;
if (f2.open(argv[2],output) == 0)
error("cannot open input file",argv[2]);
ostream to(&f2);
char ch;
while (from.get(ch)) to.put(ch);
if (!from.eof || to.bad)
error("something strange happened",");
}
1
...
77
78
79
80
81
82