小编Ace*_*7k3的帖子

这个用法有时候有必要吗?

只是偶然发现了一些我无法解释的事情.以下代码无法编译

template<int a>
class sub{
protected:
    int _attr;
};

template<int b>
class super : public sub<b>{
public:
    void foo(){
        _attr = 3;
    }
};

int main(){
    super<4> obj;
    obj.foo();
}
Run Code Online (Sandbox Code Playgroud)

而当我改变_attr = 3;this->attr = 3;那里似乎没有问题.

这是为什么?有什么情况你必须使用它吗?

我曾经g++ test.cpp -Wall -pedantic编译,我得到以下错误

test.cpp: in member function 'void super<b>::foo()':
test.cpp:11:3: error: '_attr' was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

c++ templates

6
推荐指数
1
解决办法
105
查看次数

如何在 Docker 容器中提供自定义名称解析

假设我有以下文件结构

\n\n
.                                  \n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 docker-compose.yml             \n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 webserver                      \n    \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Dockerfile                 \n    \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 html                       \n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 test1                  \n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.html         \n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test2                  \n    \xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.html         \n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 vhosts.conf                \n\n4 directories, 5 files\n
Run Code Online (Sandbox Code Playgroud)\n\n

docker-compose.yml

\n\n
version: "3.1"\nservices:\n\n    webserver:\n        build: webserver\n        container_name: web\n        working_dir: /application\n        volumes:\n            - ./webserver/html/:/application\n        ports:\n            - "80:80"\n\n    other:\n        image: php:7.2.7\n        container_name: other\n        tty: true\n
Run Code Online (Sandbox Code Playgroud)\n\n

Dockerfile

\n\n
FROM php:7.2.7-apache\n\nCOPY vhosts.conf /etc/apache2/sites-enabled/000-default.conf\n
Run Code Online (Sandbox Code Playgroud)\n\n

vhosts.conf

\n\n
<VirtualHost *:80>\n …
Run Code Online (Sandbox Code Playgroud)

dns virtualhost docker docker-compose

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

标签 统计

c++ ×1

dns ×1

docker ×1

docker-compose ×1

templates ×1

virtualhost ×1