Jump to content

Recommended Posts

Posted

Sa se creeze o clasa care retine informatii despre carti


#include <iostream>

#include <string>

#include <cstring>

#include <cstdlib>


using namespace std;


const int IN=1;

const int checked_out=0;


class book{

	char author[40];

	char title[40];

	int status;


public:

	book(char *n, char *t, int s);

	int get_status(){return status;}

	void get_status(int s){status=s;}

	void show();

};

book::book(char *n, char *t, int s)

{

	strcpy_s(author, n);

  strcpy_s(title, n);

	status=s;

}

void book::show()

{

	cout<<title<<" by "<<author;

	cout<<" is";

	if(status==IN)

		cout<<"in. \n";

	else

		cout<<"out. \n";

}

int main()

{

	book b1("Twain", "Tom Sawyer", IN);

	book b2("Melville", "Moby Dick", checked_out);


	b1.show();

	b2.show();


	system("PAUSE");

	return 0;

}

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.