Задание 7 и 8 по классам
Традиционное задание по теме: Наследование. Производные классы.
Последовательность работы конструкторов и деструкторов производных классов - 2god_2012_N10_derived_class
#include "stdafx.h"
#include <conio.h>
#include <stdio.h>
using namespace System;
class Base{public: Base(void); ~Base(void); } ;
//public
class Derive1 : public Base
{ public: Derive1(void); ~Derive1(void); };
//public
class Derive2 : public Derive1
{public: Derive2(void); ~Derive2(void); };
Base::Base(void){ puts("Const. Base");}
Base::~Base(void){ puts("Destr. Base");}
Derive1::Derive1(void){ puts("Consr. Device1");}
Derive1::~Derive1(void){ puts("Destr. Device1");}
Derive2::Derive2(void){ puts("Const. Device2");}
Derive2::~Derive2(void){ puts("Destr. Device2");}
int main(array ^args)
{
Console::WriteLine(L"Hello Derived Class");
puts("Input Index: "); int Index;
scanf("%i",&Index);
if(Index>5)Index=5;if(Index<0)Index=0;
if(Index==0) {Base b1;};
if(Index==1) {Derive1 d1; };
if(Index==2) {Derive2 d2;};
if(Index==3) {Derive1 d1;Derive2 d2;};
if(Index==4) {Base b1;Derive1 d1;};
if(Index==5) {Base b1;Derive1 d1;Derive2 d2;};
getch(); return 0;
}
Дополнительное задание 8-а
Написать программу с формой по заданию: полигональная форма.
Результат работы программы:
Рекомендуемые видеоуроки и информационные ссылки
Основные:
Дополнительные: