C++第12章项目,ATM机模拟队列。
2015-06-17 21:18
302 查看
//笔记:
c++中私有函数只能被自己的成员函数调用,而不能类外部的成员调用。
也就是说,类的对象是不能直接调用私有函数的。要间接调用。例如:
class base
{
private:
fun1();
public:
pubFunc1() { func1();} //输出base私有函数
};
int main()
{
base b;
……
b.pubFunc1(); //间接调用base类私有函数func1
}
出列:
bool Queue::dequeque(Item & item){
if(front == NULL)
return false;
item = front->item;
items–;
Node* temp = front;
front = front->next;
delete temp;
if(items == 0)
rear = NULL;
return true;
}
c++中私有函数只能被自己的成员函数调用,而不能类外部的成员调用。
也就是说,类的对象是不能直接调用私有函数的。要间接调用。例如:
class base
{
private:
fun1();
public:
pubFunc1() { func1();} //输出base私有函数
};
int main()
{
base b;
……
b.pubFunc1(); //间接调用base类私有函数func1
}
出列:
bool Queue::dequeque(Item & item){
if(front == NULL)
return false;
item = front->item;
items–;
Node* temp = front;
front = front->next;
delete temp;
if(items == 0)
rear = NULL;
return true;
}
相关文章推荐
- C++第13章 类继承
- C++ 中拷贝构造函数被调用情况
- 万年历(C语言版)
- c语言笔记
- [转]100个经典C语言程序(益智类问题)
- C++ Primer第一章(submit 转换格式)
- C++ Primer第一章
- C++12.1.3 类定义----typedef同义词、成员函数重载、指明inline
- chapter13test2
- C++ 学习笔记一易忽略的地方
- chapter13test1
- 排序算法——希尔排序
- POJ 2136 Vertical Histogram
- C++使用localtime函数需要注意的地方
- 浅谈指针的偏移
- C++下关于XML开源库的使用
- C++ 字符串查找例子.
- UC Browser
- [C++]string类的查找函数
- C++ 无法解析的外部符号