Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

lab - Vova / !_! / main

.cpp
Скачиваний:
6
Добавлен:
15.06.2014
Размер:
1.01 Кб
Скачать
#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();
}
Соседние файлы в папке !_!
  • #
    15.06.201419.46 Кб6!_!.ncb
  • #
    15.06.2014895 б7!_!.sln
  • #
    15.06.20147.17 Кб6!_!.suo
  • #
    15.06.20143.36 Кб7!_!.vcproj
  • #
    15.06.20141.01 Кб6main.cpp