| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 604 人关注过本帖
标题:关于类的问题 这是出了什么问题啊?
只看楼主 加入收藏
qq384200403
Rank: 2
等 级:论坛游民
帖 子:35
专家分:39
注 册:2013-3-1
结帖率:87.5%
收藏
已结贴  问题点数:10 回复次数:5 
关于类的问题 这是出了什么问题啊?
#ifndef __CSTU_H__
#define __CSTU_H__
class CStu
{
 protected:
    char m_No[11];            
    char m_Name[11];         
    unsigned short  m_Age;  
    char m_Sex[3];            
    char *m_Rem;              
    unsigned int m_RemBytes;   
 public:
    void Show();                     
    unsigned int GetRemBytes();      
    bool SetNo(char *No);            
    char *GetNo();                        
    bool SetName(char *Name);         
    char *GetName();                          
    bool SetAge(unsigned short Age);  
    unsigned short GetAge();               
    bool SetRem(char *Rem);           
    char *GetRem();                          
    bool SetSex(char *Sex);           
    char *GetSex();
    CStu(const CStu &s);

};   
#endif
   #include"StdAfx.h"
#include <iostream>
#include <string>
#include "CStu.h"
using namespace std;
void CStu::Show()      
{
   cout<<"学号:"<<m_No<<endl;
   cout<<"姓名:"<<m_Name<<endl;
   cout<<"性别:"<<m_Sex<<endl;
   cout<<"年龄:"<<m_Age<<endl;
   cout<<"简历:"<<m_Rem<<endl;
}
unsigned int CStu::GetRemBytes()
{
    return m_RemBytes;
}
bool CStu::SetNo(char *No)
{
  if(strlen(No)!=10 )  
         return false;
  else
         strcpy(m_No,No);
  return true;  
}

char * CStu::GetNo()
{
    return m_No;
}
bool CStu::SetName(char *Name)
{
  if(strlen(Name)>=10 )
      return false;
  else
      strcpy(m_Name,Name);
  return true;  
}

char * CStu::GetName()
{
  return m_Name;
}
bool CStu::SetAge(unsigned short Age)
{
    if(Age>=60)  
        return false;
    else
        m_Age=Age;
    return true;
}

unsigned short CStu::GetAge()
{
    return m_Age;
}
bool CStu::SetRem(char *Rem)
{
    int Len=strlen(Rem);
    char *p=new char[Len+1];
             if(p==NULL)        
         return false;
            if(m_Rem!=NULL)
          delete []m_Rem;  
    m_RemBytes=Len;
    m_Rem=p;   
    strcpy(m_Rem,Rem);  
    return true;
}
char * CStu::GetRem()
{
    return m_Rem;
}
bool CStu::SetSex(char *Sex)
{
    if(strcmp("男",Sex)==0 || strcmp("女",Sex)==0)
      {
        strcpy(m_Sex,Sex);
        return true;
      }
    else                    
           return false;   
}

char *CStu::GetSex()
{
    return m_Sex;
};
CStu::CStu(const CStu &s)
{
  strcpy(m_No,s.m_No);         
  strcpy(m_Name,s.m_Name);
  strcpy(m_Sex,s.m_Sex);      
  m_Age=s.m_Age;                 
  if(s.m_Rem!=NULL)
   {
    m_RemBytes=s.m_RemBytes;
    m_Rem=new char[m_RemBytes+1];  
    strcpy(m_Rem,s.m_Rem);
   }
  else
   {
      m_Rem=NULL;
      m_RemBytes=0;
   }
  cout<<调用了复制函数<<end1;
}
 
 
#include"StdAfx.h"
#include <iostream>
#include <string>
#include "CStu.h"
using namespace std;
void main ()
{
    CStu s1("3110413030");
    s1.Show();
}   
   运行时提示 fatal error C1083: Cannot open precompiled header file: 'Debug/MY.pch': No such file or directory
  并且总是提示STDAFX.H 出错啊
图片附件: 游客没有浏览图片的权限,请 登录注册

搜索更多相关主题的帖子: void public 
2013-03-21 12:53
peach5460
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:武汉
等 级:贵宾
威 望:30
帖 子:2780
专家分:6060
注 册:2008-1-28
收藏
得分:2 
找不到预编译头就把这行注释掉呗

我总觉得授人以鱼不如授人以渔...
可是总有些SB叫嚣着:要么给代码给答案,要么滚蛋...
虽然我知道不要跟SB一般见识,但是我真的没修炼到宠辱不惊...
2013-03-21 13:49
Pirelo
Rank: 7Rank: 7Rank: 7
等 级:黑侠
帖 子:118
专家分:550
注 册:2011-1-28
收藏
得分:2 
"No such file or directory"
下面这两个文件都找不到,你确定它们存在?
#include "StdAfx.h"
#include "CStu.h"
2013-03-21 14:01
明天更好山鹰
Rank: 2
等 级:论坛游民
威 望:1
帖 子:23
专家分:30
注 册:2013-3-11
收藏
得分:2 
新手求学习
2013-03-21 15:32
周骙骙
Rank: 2
等 级:论坛游民
帖 子:7
专家分:23
注 册:2013-3-7
收藏
得分:2 
stdfax.h好像是MFC中的头文件吧
2013-03-22 10:46
gezhongfeng
Rank: 1
等 级:新手上路
帖 子:7
专家分:5
注 册:2013-2-2
收藏
得分:2 
#ifndef __SS_H__
#define __SS_H__
class CStu
{
protected:
    char m_No[11];            
    char m_Name[11];         
    unsigned short  m_Age;  
    char m_Sex[3];            
    char *m_Rem;              
    unsigned int m_RemBytes;   
public:
    void Show();                     
    unsigned int GetRemBytes();      
    bool SetNo(char *No);            
    char *GetNo();                        
    bool SetName(char *Name);         
    char *GetName();                          
    bool SetAge(unsigned short Age);  
    unsigned short GetAge();               
    bool SetRem(char *Rem);           
    char *GetRem();                          
    bool SetSex(char *Sex);           
    char *GetSex();
    CStu(const CStu &s);

    CStu(char No[11],char Name[11],unsigned short  Age,char Sex[3],    char *Rem,unsigned int RemBytes);

   
};   
 #endif
 //#include"StdAfx.h"
 #include <iostream>
 #include <string>

 #include "ss.h"
 using namespace std;

 void CStu::Show()      
 {
    cout<<"学号:"<<m_No<<endl;
    cout<<"姓名:"<<m_Name<<endl;
    cout<<"性别:"<<m_Sex<<endl;
    cout<<"年龄:"<<m_Age<<endl;
    cout<<"简历:"<<m_Rem<<endl;
 }
 unsigned int CStu::GetRemBytes()
 {
     return m_RemBytes;
 }
 bool CStu::SetNo(char *No)
 {
   if(strlen(No)!=10 )  
          return false;
   else
          strcpy(m_No,No);
   return true;  
 }

 char * CStu::GetNo()
 {
     return m_No;
 }
 bool CStu::SetName(char *Name)
 {
   if(strlen(Name)>=10 )
       return false;
   else
       strcpy(m_Name,Name);
   return true;  
 }

 char * CStu::GetName()
 {
   return m_Name;
 }
 bool CStu::SetAge(unsigned short Age)
 {
     if(Age>=60)  
         return false;
     else
         m_Age=Age;
     return true;
 }

 unsigned short CStu::GetAge()
 {
     return m_Age;
 }
 bool CStu::SetRem(char *Rem)
 {
     int Len=strlen(Rem);
     char *p=new char[Len+1];
              if(p==NULL)        
          return false;
             if(m_Rem!=NULL)
           delete []m_Rem;  
     m_RemBytes=Len;
     m_Rem=p;   
     strcpy(m_Rem,Rem);  
     return true;
 }
 char * CStu::GetRem()
 {
     return m_Rem;
 }
 bool CStu::SetSex(char *Sex)
 {
     if(strcmp("男",Sex)==0 || strcmp("女",Sex)==0)
       {
         strcpy(m_Sex,Sex);
         return true;
       }
     else                    
            return false;   
 }

 char *CStu::GetSex()
 {
     return m_Sex;
 };
 CStu::CStu(const CStu &s)
 {
   strcpy(m_No,s.m_No);         
   strcpy(m_Name,s.m_Name);
   strcpy(m_Sex,s.m_Sex);      
   m_Age=s.m_Age;                 
   if(s.m_Rem!=NULL)
    {
     m_RemBytes=s.m_RemBytes;
     m_Rem=new char[m_RemBytes+1];  
     strcpy(m_Rem,s.m_Rem);
    }
   else
    {
       m_Rem=NULL;
       m_RemBytes=0;
    }
   cout<<"调用了复制函数"<<endl;
 }

CStu::CStu(char No[11],char Name[11],unsigned short  Age,char Sex[3],    char *Rem,unsigned int RemBytes)
{

     strcpy(m_No,No);         
     strcpy(m_Name,Name);
     strcpy(m_Sex,Sex);      
     m_Age=Age;                 
     if(Rem!=NULL)
     {
         m_RemBytes=RemBytes;
         m_Rem=new char[m_RemBytes+1];  
         strcpy(m_Rem,Rem);
     }
     else
     {
         m_Rem=NULL;
         m_RemBytes=0;
    }

   
}
////////////////////
//#include"StdAfx.h"
#include <iostream>
#include <string>
#include "ss.h"
using namespace std;
void main ()
{
    CStu s1("1","wu",34,"M","3110413030",10);
    s1.Show();
 }
2013-03-22 11:11
快速回复:关于类的问题 这是出了什么问题啊?
数据加载中...
 
   



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

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