#include
using namespace std;
//inline内联函数,在类内部的函数称作是内联函数
// 类 C++的特点:抽象 封装 继承 多态
class CGoods
{
public:
void RegisterGoods(char* name, int count, float price)
{
strcpy(name, name);
count = c;
price = p;
}
void GetName(char* name)
{
strcpy(name, m_name);
}
int GetCout()
{
return m_count;
}
private:
char m_name[10];
int m_count;
float m_price;
float m_total_price;
};
//当类里面的函数放在类外实现时,需要加上作用域
void CGood::RegisterGoods(char* name, int count, float price)
{
strcpy(m_name, name);
m_count = count;
m_price = price;
}
void main()
{
CGoods c;
}
//所占空间大小
class Test
{
public:
void SetData(int data)
{
m_data = data;
}
int GetData()const//常方法
{
return m_data;
}
char m_data0;//1+3
int m_data;//4
int m_data;//4 该结构体共占12个字节
//日期类
class Date
{
public:
void Display()
{
cout << _year << "-" << _month << "-" << _day << endl;
}
void SetDate(int year, int month, int day)
{
_year = year;
_month = month;
_day = day;
}
private:
int _year;
int_month;
int_day;
};
};
class Test()
{
public:
//下面两个函数可以同时存在,因为函数的参数不一样
//Test*const this
void fun()
{}
//const Test*const this
void fun()const
{}
}



