标题:怎么使类声明和成员函数分离
取消只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-246245-1-1.html




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

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