小编Cha*_*all的帖子

在这样的类之后,如何使用"this"?

我不太明白this在这个例子中如何使用关键字.

private void checkForComodification() {
    // The this I'm concerned about is the first one
    if (CyclicArrayList.this.modCount != this.modCount)
        throw new ConcurrentModificationException();
}
Run Code Online (Sandbox Code Playgroud)

java this

3
推荐指数
1
解决办法
122
查看次数

这个C++标识符是如何定义的?

好吧,所以我正在尝试学习C++,并且我有两个对象,它们都是父类("游戏")的子类("testgame").以下是两者的定义:

//game.h
#pragma once
#include <string>
class game
{
public:
    virtual ~game() {

    }
    virtual std::string getTitle() = 0;
    virtual bool setup() = 0;
    virtual void start() = 0;
    virtual void update() = 0;
};
Run Code Online (Sandbox Code Playgroud)

和testgame

//testgame.h
#pragma once
#include "game.h"
#include <iostream>
class testgame :
    public game
{
public:
    std::string name;

    testgame(std::string name) {
        this->name = name;
    }
    ~testgame() {
        std::cout << name << " is being destroyed..." << std::endl;
        delete this;
    }
    bool setup() {
        std::cout << name …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance

3
推荐指数
1
解决办法
88
查看次数

标签 统计

c++ ×1

inheritance ×1

java ×1

this ×1