Добавил:
Yanus
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:lab - Vova / !_! / main
.cpp#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class test
{
public:
test();
test(char *lng);
~test();
bool print();
private:
int ind;
char hello[3][10];
char lang[3][10];
};
test::test()
{
strcpy(this->hello[0], "yes");
this->ind = 0;
}
test::test(char *lng)
{
strcpy(this->hello[0], "yes");
strcpy(this->hello[1], "ja");
strcpy(this->hello[2], "da");
strcpy(this->lang[0], "en");
strcpy(this->lang[1], "gr");
strcpy(this->lang[2], "ru");
this->ind = -1;
for (int i=0; i<3; i++)
{
if (strcmp(lng, this->lang[i])==0)
{
this->ind = i;
break;
}
}
}
test::~test() {}
bool test::print()
{
if (this->ind == -1) return false;
else printf("%s", this->hello[this->ind]);
return true;
}
void main(int argc, char *argv[])
{
test *var;
if (argc < 2)
{
printf("not enought parameters");
getchar();
exit(1);
}
var = new test(argv[1]);
var->print();
delete var;
getchar();
}