Two x C++CC programs

Source: Internet
Author: User

#include <iostream>
#include <string>
using namespace Std;

Class Book
{
Public
Book (string na, string au, int. page, float price):
Name (NA), author (AU), page (page), price
{
cout<< "title:" <<name<<endl
<< "" <<author<<endl
<< "Pages:" <<page<<endl
<< "Price:" <<price<<endl;
}

Book(string na, string au):    name(na),author(au){    cout<<"书名:"<<name<<endl        <<""<<author<<endl;}Book(){    cout<<"新建Book对象"<<endl;}Book(const Book &b)

{
name = B.name;
Author = b.author;
page = B.page;
Price = B.price;
cout<< "title:" <<name<<endl
<< "" <<author<<endl
<< "Pages:" <<page<<endl
<< "Price:" <<price<<endl;
}

~Book(){    cout<<"回收Book对象"<<endl;}

Private
String name;
string author;
int page;
float price;
};

int main ()
{
Book B1 ("sa", "Zero", 12,34);
Book B2 ("sa", "Zero");
Book B3;
Book B4 = b1;
return 0;
}
#include <iostream>
#include <math.h>
using namespace Std;
Class Point
{
Public
Point (int a,int B): X (a), Y (b) {}
void display ();
Friend Float Sum (point &,point &);
Private
int x;
int y;
};

void point::d isplay ()
{
cout<<x<< "," <<y<<endl;
}
Float Sum (Point &m,point &n)
{
float Su;
Su = sqrt ((m.x-n.x)(m.x-n.x) + (M.Y-N.Y)(M.Y-N.Y));
cout<<su<<endl;
}

int main ()
{
Point B1 (4,6);
Point B2 (2,3);
B1.display ();
B2.display ();
Sum (B1,B2);
return 0;
}

Two x C++CC programs

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.