游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1353|回复: 3

关于C的项目类对象声明,不知错在那了?

[复制链接]

29

主题

97

帖子

99

积分

注册会员

Rank: 2

积分
99
发表于 2005-9-20 09:37:00 | 显示全部楼层 |阅读模式
#include<iostream>
#include<conio.h>
#include<atlbase.h>
class A{
        public:
int a;

int first(int *h,int n){

        ATLTRACE2("First%s\n","First");
       
        go(h,n);
       
        return 0;
};

int virtual go(int *h,int n)
        {
       if (n==0) return 0;
           ATLTRACE2("ClassA:%i\n",*h);
           *h=*h-5;
          
           go(h,n-1);
          
           return 0;
        };

};


class B:public A{
public:
         B(int g);
        ~B(void);
        int b;

int go(int *h,int n)
        {
       
                ATLTRACE2("ClassB: %i\n",*h);
                return A::go(h,n);
        };

};



void main()
{
        int y=0;
       
        B *b=NULL;
        B *bb=new B(y);

        B CB(y);
        b=&CB;

        A CA;
        A *a=NULL;
        a=&CA;

        int i=100;

        //a->first(&i,5);

        bb->first(&i,5);
        ATLTRACE2("%d\n",i);
       
}

44

主题

156

帖子

162

积分

注册会员

Rank: 2

积分
162
发表于 2005-9-20 18:07:00 | 显示全部楼层

Re:关于C的项目类对象声明,不知错在那了?

class B:public A{
public:
        B(int g){};
        ~B(void){};
        int b;
        int go(int *h,int n)
        {
                ATLTRACE2("ClassB: %i\n",*h);
                return A::go(h,n);
        };
};

44

主题

156

帖子

162

积分

注册会员

Rank: 2

积分
162
发表于 2005-9-20 18:08:00 | 显示全部楼层

Re:关于C的项目类对象声明,不知错在那了?

B函数的,创建和析构都没有处理,所以出现上面的错误!

29

主题

97

帖子

99

积分

注册会员

Rank: 2

积分
99
 楼主| 发表于 2005-9-21 21:16:00 | 显示全部楼层

Re:关于C的项目类对象声明,不知错在那了?

谢谢了,知道了
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-22 02:08

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表