| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1321 人关注过本帖
标题:怎么使类声明和成员函数分离
取消只看楼主 加入收藏
lionmusicyj
Rank: 1
等 级:新手上路
帖 子:98
专家分:0
注 册:2008-9-20
结帖率:100%
收藏
 问题点数:0 回复次数:0 
怎么使类声明和成员函数分离
//student.h
class student
{
   public:
      student(int n):num(n){}
      void display();
   private:
      int num;
      string name;
      char sex;
};
//student.cpp
#include <iostream>
#include "student.h"
void student::display()
{
  cout<<"num"<<num;
}

为什么我写这个主函数会出现链接错误?
#include <iostream>
#include <string>
#include "student.h"
using namespace std;
int main()
{
  student s(7);
  s.display();
  system("pause");
  exit(1);
}
希望大家指教下小弟哈~!
搜索更多相关主题的帖子: 函数 声明 成员 
2008-11-25 23:14
快速回复:怎么使类声明和成员函数分离
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019314 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved