您现在的位置: > 首页 > 程序开发 > C语言教程
>> 最新教程
>> 热门教程
>> 最新游戏资讯
>> 热门游戏资讯
c++之静态成员的初始化实例介绍
作者:                来自:安迪教程网                 加入时间:10-10-19                进入论坛讨论
  1. #pragma once
  2. class CStudent
  3. {
  4. public:
  5.     CStudent(void);
  6.     CStudent(int age,int score);
  7. public:
  8.     ~CStudent(void);
  9. public:
  10.     int age;
  11.     int score;
  12.     static int totalScore;
  13. };
  14. #include "StdAfx.h"
  15. #include "Student.h"
  16. CStudent::CStudent(void)
  17. {
  18. }
  19. CStudent::~CStudent(void)
  20. {
  21. }
  22. CStudent::CStudent(int age, int score)
  23. {
  24.     this->age=age;
  25.     this->score=score;
  26.     totalScore =score;
  27. }
  28. int CStudent::totalScore=0;


注意:在类外初始化 这和C#不同
联系方式:QQ:6084884 email:agwcn@126.com 粤ICP备10101711号
本网站中发布的文章只代表发表人的个人观点,不代表安迪教程网网站的立场
copyright© 2000-2004 安迪教程网 All rights reserved agwcn.com