12 2011 档案

怎么将一个类的成员函数作为指针传递给另一个类的成员函数
摘要:今天帮同学解决了一个问题,怎么把一个类的成员函数作为指针传递给另一个类的成员函数。以前只接触过C语言中的函数指针:#include <iostream.h>void add(int a,int b){cout<<"the value of add is "<<a+b<<endl;}void mul(int a,int b){cout<<"the value of multiple is "<<a*b<<endl;}/*void (*fun)(int,int)是要传入的函数 阅读全文

posted @ 2011-12-24 20:26 沉沉-_- 阅读(5344) 评论(0) 推荐(0)

C++中关于流的概念
摘要:怎么从键盘中读取一个整数并包括错误处理int a;while (cin.get(ch1)) { if (ch1=='\n') cout<<"input the right number:"; //第一次输入换行; else if (cin.get(ch2),ch2=='\n') { a=ch1-'0'; if (a>0 && a<10) break; else cout<<"input the right number:"; //一位数字输入错误; } e 阅读全文

posted @ 2011-12-15 21:00 沉沉-_- 阅读(332) 评论(0) 推荐(0)

导航