class MyClass:public CObject
{};
还有别的方法吗?

解决方案 »

  1.   

    那该如何组织.h he.cpp?
    他们需要什么头文件?
      

  2.   

    1、自己写一个.h 和 .cpp文件,把他们包含进工程里来
    2、在insert菜单栏里找“新建类”菜单项,打开的对话框里有class type下拉框,这里有general class项,选定他,在下面的Base Class编辑框里加入基类CObject,给自己的类取个名字,点OK。在workspace里添加你所需的成员函数及变量。
      

  3.   


    而且,像你说的那样作的话,
    编译出错。
    fatal error C1010: unexpected end of file while looking for precompiled header directive
      

  4.   

    VC提供的呀,
    对了,要#include<afx.h>
      

  5.   

    在你的CPP文件中加上一句:#include "stdafx.h",否则就会出现你说的错误
      

  6.   

    不行,
    #include<afx.h>没用。
      

  7.   

    #include<stdafx.h>
    只会增加错误。
      

  8.   

    记得加到CPP文件的最上面,因为在这句以前的编译器是不会编译的。
      

  9.   

    stdafx.h是预编译头文件,是最先要被编译的,如果出现找不到的错误你去看看vc的设置吧
      

  10.   

    选择insert菜单,Newclass,在class type中选取Generic Class,
    在Basic Class(es)中的Derived From下键入CObject。搞定。
      

  11.   

    stdafx.h是预编译头文件,是最先要被编译的,如果出现找不到的错误你去看看vc的设置吧
      

  12.   

    //age.h
    class CAge : public CObject
    {
    public:
    int m_year;
    CAge(){m_year=0} ;
    void Display();
    ~CAge();
    }
    //.cpp
    #include "stdafx.h"
    #include "age.h"void CAge::Display()
    {
    return;
    }
    CAge::~CAge()
    {
    }
    这是我写的。
    可是编译:出来3个错误。
      

  13.   

    如果去掉#include<stdafx.h>
    编译出现:
    unexpected end of file while looking for precompiled header directive
      

  14.   

    CAge(){m_year=0};
    有逗号?
    哪三个错?
      

  15.   

    我从CCmdTarget派生CAge
    然后改动代码,去掉一些CCmdTarget类所有的信息,
    由从CObject派生,代码与我自己编的就差#include<stdafxh>
      

  16.   

    1。'CAge' followed by 'void' is illegal (did you forget a ';'?)
    2。class CAge __thiscall CAge::Display(void)' : overloaded function differs only by return type from 'void __thiscall CAge::Display(void)'
    3。'Display' : redefinition; different basic types
      

  17.   

    请问有没有从CObject亲自派生过自己的类?