首页 > 其他 > 详细

对象指针

时间:2016-05-26 14:35:43      阅读:161      评论:0      收藏:0      [点我收藏+]

// 对象指针.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
using namespace std;
class Student
{
    int id;
    char name[10];
    float score;
public:
    Student(int pid, char *pname, float s);
    void displsy();
};


Student::Student(int pid, char * pname, float s)
{
    id = pid;
    strcpy(name, pname);
    score = s;
}

void Student::displsy()
{
    cout << "id:" << id << endl;
    cout << "name:" << name << endl;
    cout << "score:" << score << endl;
}
int main()
{
    Student s1(1511435,"nankai",56);
    s1.displsy();
    Student *p = &s1;
    p->displsy();
    return 0;
}
技术分享

对象指针

原文:http://www.cnblogs.com/summercloud/p/5530833.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!