Lzp729@Blog
道法自然
Browse: Home / 类

类

Python知识整理 (21) 类代码编写基础

By lzp729 on November 28, 2010

代码1: 类外或者对象外增加属性成员

class baseClass:
def __init__(self, value):
self.a = value
 
a = baseClass("2")
 
baseClass.bAtt = "1"
b = baseClass("3")
print baseClass.bAtt # 输出1
print baseClass.a # 编译错误
print a.bAtt [...]

Posted in Python知识整理 | Tagged Python, 属性, 知识整理, 类 | Leave a response

C++知识整理 (8) 类

By lzp729 on June 17, 2009

类就是定义了一个新的类型和一个新的作用域.
class 中可用描述符public:, protected:, private:, static, mutable, friend
eg:

class Sales_Item
{
public:
double avg_price() const;
bool same_isbn(const &) const;
Sales_Item():units(0), revenue()0,0){}
private:
std::string isbn;
[...]

Posted in C++知识整理 | Tagged C++, 知识整理, 类 | Leave a response

类

  • Python知识整理 (21) 类代码编写基础
  • C++知识整理 (8) 类

Copyright © 2012 Lzp729@Blog.

Powered by WordPress and Hybrid, Theme By Lzp729.

RSS feed Site Map