小编lir*_*onz的帖子

c ++自动'类型转换'转换

有人可以解释为什么下面的代码不能在错误时编译:

Error   1   error C2243: 'type cast' : conversion from 'Der *' to 'Base *' exists, but is inaccessible  d:\users\lzizva\documents\mta\c++\projects\temp1\17022014.cpp   50  1   temp1
Error   2   error C2243: 'type cast' : conversion from 'Der *' to 'Base *' exists, but is inaccessible  d:\users\lzizva\documents\mta\c++\projects\temp1\17022014.cpp   51  1   temp1
    3   IntelliSense: conversion to inaccessible base class "Base" is not allowed   d:\users\lzizva\documents\mta\c++\projects\temp1\17022014.cpp   50  12  temp1
    4   IntelliSense: conversion to inaccessible base class "Base" is not allowed   d:\users\lzizva\documents\mta\c++\projects\temp1\17022014.cpp   51  14  temp1
Run Code Online (Sandbox Code Playgroud)

我认为当有私有继承时,子进程获取所有属性和方法并将它们设置为私有,它只会影响子进程的子类.我在这里错过了什么?编译器实际上做了什么?

提前谢谢,Liron

#include <iostream>

using …
Run Code Online (Sandbox Code Playgroud)

c++ types casting

2
推荐指数
1
解决办法
528
查看次数

标签 统计

c++ ×1

casting ×1

types ×1