码迷,mamicode.com
首页 > 其他好文 > 详细

对象指针

时间:2016-05-26 14:38:55      阅读:113      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!