请看下面的代码:

//xy_3_1   2013/10/26
#include<stdio.h>
#include<iostream.h>
#include<string.h> class Student{
public:
Student(){};
Student(Student &p);
int no;
char name[];
float score1;
float score2;
float score3;
void input();
void display();
void display1(); private:
Student *ptr; }; Student::Student(Student &p){ //construct memeber;
ptr=&p; } void Student::input(){
Student *w;
w=ptr;
cout<<"请输入学生 姓名 学号 成绩1 成绩2 成绩3"<<endl;
for(int i=;i<;i++){
cin>>w->name>>w->no>>w->score1>>w->score2>>w->score3;
w++;
}
} void Student::display(){
Student *w;
w=ptr;
cout<<"输出数据:"<<endl;
cout<<"姓名"<<'\t'<<"学号"<<'\t'<<"成绩1"<<'\t'<<"成绩2"<<'\t'<<"成绩3"<<endl;
for(int i=;i<;i++){
cout<<w->name<<'\t'<<w->no<<'\t'<<w->score1<<'\t'<<w->score2<<'\t'<<w->score3<<endl;
w++;
}
}
int main()
{ Student *a=new Student[];
a->input();
a->display();
return ;
}

我想实现 类数组的一个传递接口 实现的代码如上面的那样  但是我却不知道如何把数组的下标给传递进类的接口中 从而实现封装  正如上面的输入和输出的循环数组中的 3 ,我本来想在main中吧这个 3 给传递进构造函数中的 但我却不知道应该如何实现 如果有位好心人 路过 看到 请不吝赐教 小子感激不尽。

最新文章

  1. 使用Json Web Token设计Passport系统
  2. iOS9 适配(杂七杂八)
  3. error: could not read CFBundleIdentifier from Info.plist (null)解决方法之一
  4. linux权限补充:rwt rwT rws rwS 特殊权限
  5. JAVA对文件类型的校验
  6. IOS开发中与设计沟通之字体大小转换
  7. libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
  8. andriod GridView
  9. 常用的math函数
  10. 不加班的实践(1)——这真的该用try-catch吗?
  11. StringBuilder是不是线程安全的?
  12. 苹果试图做?XCode6 放弃prefix.pch档
  13. 阿里云CentOS搭建系统
  14. iOS 轻松实现自定义TabBar
  15. OO第四次博客作业
  16. word中插入myth type公式行距变大的问题
  17. Jexus~mono中使用StackExchange.redis的问题
  18. 在grails中远程调用action
  19. JavaScript 之 JavaScript 对象
  20. TCP连接建立与释放

热门文章

  1. 2018-2019-2 20165219《网络对抗技术》Exp4 恶意代码分析
  2. 【OCP-12c】CUUG 071题库考试原题及答案解析(15)
  3. Spring 中aop切面注解实现
  4. sonarLint和sonarQube
  5. robot framework-接口测试实例一
  6. java学习笔记_接口
  7. Linux之E: 无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它?
  8. P5242 [USACO19FEB]Cow Dating
  9. UVALive-7457-Discrete Logarithm Problem(取模运算)
  10. 对drf视图的理解