Jump to content

Constructori De Copiere-Exemplul2


skyler_sdf

Recommended Posts

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;

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.